-2

您好我正在开发一个 android SMS 应用程序并从内置消息应用程序中获取 SMS 作为

    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")); 


        }

当有任何群发短信时,我会在 myApp 中强制关闭,如下所示

 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

我如何阅读群组短信并将它们与_id进行比较。请帮忙。谢谢!

4

1 回答 1

0

我认为“4”和“8”之间的空格是问题所在。

于 2013-10-15T11:34:33.960 回答