public int readSMSMessage() {
Uri allMessage = Uri.parse("content://sms");
ContentResolver cr = getContentResolver();
Cursor c = cr.query(allMessage, new String[] { "_id", "thread_id", "address", "person", "date", "body" }, null, null, "date DESC");
String string = "";
int count = 0;
while (c.moveToNext()) {
long messageId = c.getLong(0);
long threadId = c.getLong(1);
String address = c.getString(2);
long contactId = c.getLong(3);
String contactId_string = String.valueOf(contactId);
long timestamp = c.getLong(4);
String body = c.getString(5);
string = String.format("msgid:%d, threadid:%d, address:%s, " + "contactid:%d, contackstring:%s, timestamp:%d, body:%s", messageId, threadId, address, contactId,
contactId_string, timestamp, body);
Log.d("heylee", ++count + "st, Message: " + body);
}
return 0;
}
댓글 영역