SMSList.java
public static final String MESSAGE_TYPE_INBOX = "1"; public static final String MESSAGE_TYPE_SENT = "2"; public static final String MESSAGE_TYPE_CONVERSATIONS = "3"; public static final String MESSAGE_TYPE_NEW = "new"; 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://sms/"); cur = this.getContentResolver().query(allMessage, null, null, null, null); count = cur.getCount(); Logger.i( TAG , "SMS count = " + count); String row = ""; String msg = ""; String date = ""; String protocol = ""; while (cur.moveToNext()) { row = cur.getString(cur.getColumnIndex("address")); msg = cur.getString(cur.getColumnIndex("body")); date = cur.getString(cur.getColumnIndex("date")); protocol = cur.getString(cur.getColumnIndex("protocol")); // 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"; Logger.i( TAG , "SMS Phone: " + row + " / Mesg: " + msg + " / Type: " + type + " / Date: " + date); } } catch (IOException 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) { } } }참고사이트) Mobdev Wiki
Android - Querying the SMS ContentProvider?
youropensource
Delete SMS in Android 1.5
출처 : http://www.androes.com/144
댓글 없음:
댓글 쓰기