I am trying to get all Inbox Messages using ContentResolver based on message ids stored in another table..
I want to exclude all Inbox SMSs whose message id is not in my custom table(spam_msgids).
What i am doing is (I dont know whether this is correct or not):
Uri uriSms=Uri.parse("content://sms/inbox");
Cursor cursor = context.getContentResolver().query(uriSms, null,"_id NOT IN (SELECT msg_id FROM spam_msgids)",null,null);
But its giving me an error though table is already created …
Error : 07-19 17:04:16.412: ERROR/DatabaseUtils(141):
android.database.sqlite.SQLiteException: no such table: spam_msgids: , while compiling: SELECT * FROM sms WHERE (type=1) AND (_id NOT IN (SELECT msg_id FROM spam_msgids)) ORDER BY date DESC
Can anyone please tell me where i am going wrong ?
You can fetch all IDs from you database, build a comma separated string and pass it to NOT IN so that it would look like:
Cursor cursor = context.getContentResolver().query(uriSms, null,"_id NOT IN (" + stringOfCommaSeparatedStringOfIDs + ")",null,null);