2

I have fetched all message from a particular number from inbox by the following code .

public void refreshSmsInbox() {
        ContentResolver contentResolver = getContentResolver();
        Cursor smsInboxCursor = contentResolver.query(
                Uri.parse("content://sms/inbox"), null, null, null, null);
        int indexBody = smsInboxCursor.getColumnIndex("body");
        int indexAddress = smsInboxCursor.getColumnIndex("address");
        if (indexBody < 0 || !smsInboxCursor.moveToFirst())
            return;
        arrayAdapter.clear();
        do {
            if (pre_address.equals(smsInboxCursor.getString(indexAddress))) {
                String str = "SMS From: "
                        + smsInboxCursor.getString(indexAddress) + "\n"
                        + smsInboxCursor.getString(indexBody) + "\n";
                arrayAdapter.add(str);
            }
        } while (smsInboxCursor.moveToNext());
    }

Now I want to mark which sms are read and which are unread . How can I check which sms are read and which are unread ?

How can I check whether a sms is read or unread at the time of fetching from inbox ?

osimer pothe
  • 2,827
  • 14
  • 54
  • 92

1 Answers1

0

You can get the colum index with read keyword:

int indexRead = smsInboxCursor.getColumnIndex("read");

And then in your loop you can check it like this (0 = not read and 1 = read):

boolean isRead = smsInboxCursor.getInt(indexRead) == 1;
megaturbo
  • 680
  • 6
  • 24