Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Currently lists all messages with contact numbers
- public ArrayList<String> fetchInbox() {
- String address = null;
- ArrayList<String> sms = new ArrayList<String>();
- Uri uriSms = Uri.parse("content://sms/inbox");
- Cursor cursor = getContentResolver().query(uriSms,
- new String[] { "_id", "address", "date", "body" }, null, null,
- null);
- cursor.moveToFirst();
- while (cursor.moveToNext()) {
- address = cursor.getString(1); // Displays phone number
- String body = cursor.getString(3); // Displays text message
- // phone number and message added together for each item
- sms.add(address + " " + body);
- }
- return sms;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement