Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try {
- Uri uriInbox = Uri.parse("content://sms/inbox");
- Cursor inbox = getContentResolver().query(uriInbox, null, "address IS NOT NULL) GROUP BY (thread_id", null, null); // 2nd null = "address IS NOT NULL) GROUP BY (address"
- Uri uriSent = Uri.parse("content://sms/sent");
- Cursor sent = getContentResolver().query(uriSent, null, "address IS NOT NULL) GROUP BY (thread_id", null, null); // 2nd null = "address IS NOT NULL) GROUP BY (address"
- Cursor c = new MergeCursor(new Cursor[]{inbox,sent}); // Attaching inbox and sent sms
- if (c.moveToFirst()) {
- for (int i = 0; i < c.getCount(); i++) {
- String name = null;
- String phone = "";
- String _id = c.getString(c.getColumnIndexOrThrow("_id"));
- String thread_id = c.getString(c.getColumnIndexOrThrow("thread_id"));
- String msg = c.getString(c.getColumnIndexOrThrow("body"));
- String type = c.getString(c.getColumnIndexOrThrow("type"));
- String timestamp = c.getString(c.getColumnIndexOrThrow("date"));
- phone = c.getString(c.getColumnIndexOrThrow("address"));
- if(name == null)
- {
- name = Function.getContactByPhoneNumber(getApplicationContext(), c.getString(c.getColumnIndexOrThrow("address")));
- }
- tmpList.add(Function.mappingInbox(_id, thread_id, name, phone, msg, type));
- c.moveToNext();
- }
- }
- c.close();
Add Comment
Please, Sign In to add comment