Advertisement
ChocoMan

Untitled

Jun 9th, 2012
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.65 KB | None | 0 0
  1. // Currently lists all messages with contact numbers
  2. public ArrayList<String> fetchInbox() {
  3.         String address = null;
  4.         ArrayList<String> sms = new ArrayList<String>();
  5.         Uri uriSms = Uri.parse("content://sms/inbox");
  6.        
  7.          Cursor cursor = getContentResolver().query(uriSms,
  8.          new String[] { "_id", "address", "date", "body" }, null, null,
  9.          null);
  10.  
  11.         cursor.moveToFirst();
  12.         while (cursor.moveToNext()) {
  13.             address = cursor.getString(1); // Displays phone number
  14.             String body = cursor.getString(3); // Displays text message
  15.  
  16.             // phone number and message added together for each item
  17.             sms.add(address + " " + body);
  18.         }
  19.         return sms;
  20.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement