I am creating one application which displays all Inbox sms messages. On the list of sms messages, there is a button to read all that number's conversation with me.
It is done by fetching the intent object and comparing that object to a query of records address like this function..`
public void readConversation() {
try {
StringBuilder smsBuilder = new StringBuilder();
cur = getContentResolver().query(Uri.parse(SMS_URI_ALL), null,
null, null, "date ASC");
int smsEntriesCount = cur.getCount();
Log.d("smsEntriesCount", "" + smsEntriesCount);
if (cur.moveToFirst()) {
do {
data = new HashMap<String, String>();
String smsAdress = cur.getString(
cur.getColumnIndexOrThrow("address")).toString();
String smsbody = cur.getString(
cur.getColumnIndexOrThrow("body")).toString();
String smsid = cur.getString(
cur.getColumnIndexOrThrow("_id")).toString();
String smsdate = cur.getString(
cur.getColumnIndexOrThrow("date")).toString();
String smstype = cur.getString(
cur.getColumnIndexOrThrow("type")).toString();
String smsStatus = cur.getString(
cur.getColumnIndexOrThrow("status")).toString();
String smsReadUnread = cur.getString(
cur.getColumnIndexOrThrow("read")).toString();
String contactnamelist = getContactDisplayNameByNumber(smsAdress);
if (smsAdress.equalsIgnoreCase(straddress.trim())) {
data.put("_id", smsid);
data.put("address", contactnamelist);
data.put("body", smsbody);
data.put("date", smsdate);
data.put("type", smstype);
data.put("status", smsStatus);
data.put("ReadUnread", smsReadUnread);
NumberList123.add(data);
Log.d("Conversation id", smsid);
Log.d("Conversation Address", smsAdress);
Log.d("Conversation body", smsbody);
Log.d("Conversation date", smsdate);
Log.d("Conversation type", smstype);
Log.d("Conversation status", smsStatus);
Log.d("Conversation Read(1)-Unread(0)", smsReadUnread);
}
} while (cur.moveToNext());
}
convolistnumber = new application();
convolistnumber.setListConvo(NumberList123);
Log.d(Tag, " Arraylist size " + NumberList123.size());
Log.d(Tag, "Convo List" + convolistnumber.getConvoList().size());
if (!cur.isClosed()) {
cur.close();
cur = null;
} else {
smsBuilder.append("no result!");
}
} catch (SQLiteException ex) {
ex.printStackTrace();
}
}
`
By using this function i got all conversation of that number which is "straddress" coming from main activity of button click but it gets more time becoz i search all sms address to straddress number and it takes much time...so is any solution if i check that number in query thats mean this function run quick...
I am also trying to check address in cursor but it results only sent sms of recipient and i want all sent and inbox sms that means conversation..
thanks in advance..