-2

Hi I am developing an android SMS app and fetching the SMS from built in messaging app as

    Uri uriSMSURI = Uri.parse("content://mms-sms/conversations?simple=true");
    Cursor cursor = getContentResolver().query(uriSMSURI, new String[] {"*"}, null, null, "date desc");

        while (cursor.moveToNext()) 
        {
            snippet = cursor.getString(cursor.getColumnIndexOrThrow("snippet"));
            Long date = cursor.getLong(cursor.getColumnIndexOrThrow("date"));

            recipient_ids = cursor.getString(cursor.getColumnIndexOrThrow("recipient_ids"));
            recipient_ids.split(" ");


            Cursor c = getContentResolver().query(Uri.parse("content://mms-sms/canonical-addresses"), null, "_id = " + recipient_ids, null, null);
            c.moveToFirst();
            phonenumber= c.getString(c.getColumnIndexOrThrow("address")); 


        }

When there are any group SMS , I am getting a force close in myApp as below

 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.Sms}: android.database.sqlite.SQLiteException: near "8": syntax error: , while compiling: SELECT _id, address FROM canonical_addresses WHERE _id = 4 8

How do I read Group SMS and compare them with _id. Please Help. Thanks!

sanjana
  • 641
  • 2
  • 15
  • 36

1 Answers1

0

I think the space between "4" and "8" is the problem.

ColdFaith
  • 401
  • 4
  • 13