문자 메시지 스팸 리스트 가져오기.
public void SMSList() {
try {
// Retrieve All SMS
/*
Inbox = "content://sms/inbox"
Failed = "content://sms/failed"
Queued = "content://sms/queued"
Sent = "content://sms/sent"
Draft = "content://sms/draft"
Outbox = "content://sms/outbox"
Undelivered = "content://sms/undelivered"
All = "content://sms/all"
Conversations = "content://sms/conversations"
addressCol= mCurSms.getColumnIndex("address");
personCol= mCurSms.getColumnIndex("person");
dateCol = mCurSms.getColumnIndex("date");
protocolCol= mCurSms.getColumnIndex("protocol");
readCol = mCurSms.getColumnIndex("read");
statusCol = mCurSms.getColumnIndex("status");
typeCol = mCurSms.getColumnIndex("type");
subjectCol = mCurSms.getColumnIndex("subject");
bodyCol = mCurSms.getColumnIndex("body");
*/
Uri allMessage = Uri.parse("content://mms-sms/spam-filter");
Cursor cur = this.getContentResolver().query(allMessage, null, null, null, null);
int count = cur.getCount();
for(int i=0;i<count;i++){
Log.i("heylee" , "SMS count = " + count+" "+cur.getColumnName(i));
}
// 04-18 15:26:49.844: I/heylee(17536): SMS count = 4 enable
// 04-18 15:26:49.844: I/heylee(17536): SMS count = 4 filter
// 04-18 15:25:07.684: I/heylee(16355): SMS count = 2 filter_type
String row = "";
String msg = "";
String date = "";
String protocol = "";
while (cur.moveToNext()) {
row = cur.getString(cur.getColumnIndex("_id")); //등록된 순서 대로 ... 부여되는 id 1,2,3,4,....
msg = cur.getString(cur.getColumnIndex("filter_type")); //이게 0이면 스팸 번호, 1이면 스팸문구.
date = cur.getString(cur.getColumnIndex("enable"));
protocol = cur.getString(cur.getColumnIndex("filter")); // 번호 or스팸 문
// Logger.d( TAG , "SMS PROTOCOL = " + protocol);
// String type = "";
// if (protocol == MESSAGE_TYPE_SENT) type = "sent";
// else if (protocol == MESSAGE_TYPE_INBOX) type = "receive";
// else if (protocol == MESSAGE_TYPE_CONVERSATIONS) type = "conversations";
// else if (protocol == null) type = "send";
Log.i( "heylee" , "SMS Phone: " + row + " / Mesg: " + msg + " / Type: " + date + " / Date: " + protocol);
}
} catch (Exception e) {
e.printStackTrace();
}
}
- public void SMSDelete() {
- Uri deleteUri = Uri.parse("content://sms");
- int count = 0;
- Cursor c = this.getContentResolver().query(deleteUri, null, null,
- null, null);
- while (c.moveToNext()) {
- try {
- // Delete the SMS
- String pid = c.getString(0);
- // Get id;
- String uri = "content://sms/" + pid;
- // count = this.getContentResolver().delete(Uri.parse(uri),null, null);
- } catch (Exception e) {
- }
- }
- }