开发者

Android: java.lang.IllegalArgumentException: Bad conversation thread id: 15555215554

I am trying to delete sms messages from android emula开发者_运维百科tor and receiving next error:

java.lang.IllegalArgumentException: Bad conversation thread id: 15555215554

Does someone have the same problem and can help me to resolve this problem? The code for delete message next:

    try {
        final long thread_id = transactionCursor.getLong(1);
        Uri thread = Uri.parse("content://sms/conversations/" + thread_id);
        getContentResolver().delete(thread, null, null);
    } catch (Exception e) {
        System.out.println(e.getMessage());
    }

in manifest file I have added next permissions:

<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.WRITE_SMS" /> 


Yes, Ahmet, You are right and I understand it from the error message, simply changing from my code

try {
    final long thread_id = transactionCursor.getLong(transactionCursor.getColumnIndex("thread_id"));
    final Uri thread = Uri.parse("content://sms/conversations/" + thread_id);
    final int numberOfDeletedMessages = getContentResolver().delete(thread, null, null);
    Log.v(TAG, "Number of deleted messages equals to " + numberOfDeletedMessages);
} catch (Exception e) {
    Log.e(TAG,e.getMessage(),e);
}

and all works successful.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜