I have written a code to extract the unique addresses and then the first message corresponding to that number.
The code to extract that is as follows:
Uri uri = Uri.parse("content://sms/");
String[] projection = new String[]{"DISTINCT address","thread_id","date","body"};
String grop ="address IS NOT NULL) GROUP BY (address";
Cursor c = getContentResolver().query(uri, projection, grop, null, null);
if(c.moveToFirst()) {
for(int i=0; i < c.getCount(); i++) {
SMSData sms = new SMSData();
sms.setThreadId(c.getString(c.getColumnIndexOrThrow("thread_id")).toString());
sms.setNumber(c.getString(c.getColumnIndexOrThrow("address")).toString());
sms.setBody(c.getString(c.getColumnIndexOrThrow("body")).toString());
sms.setDate((new Date(Long.parseLong(c.getString(c.getColumnIndexOrThrow("date")).toString()))).toString());
smsList.add(sms);
c.moveToNext();
}
}
c.close();
However the same number say XXX is simply retrieved as XXX from the inbox messages whereas the same number XXX from the outbox is retrieved with the country code appended to it as +91XXX, so after retrieving I see the two entry for the same number XXX in which one is for XXX and other is for +91XXX.
I want that for the same number even if it is appended with the country code only row entry will get retrieved.
Please help this functionality is required for me to proceed further. Thanks in Advance.
0 comments:
Post a Comment