实际上我想根据id使用以下代码
从收件箱中删除短信但显示错误
我的代码:
Uri deleteUri = Uri.parse("content://sms/");
Cursor m_cCursor=context.getContentResolver().query(deleteUri, null, null, null, null);
int m_cnum=m_cCursor.getCount();
int id =m_cCursor.getInt(0);
int thread_id = m_cCursor.getInt(1);
错误是:
0 new java.lang.RuntimeException [2]
3 dup
4 ldc <String "Stub!"> [3]
6 invokespecial java.lang.RuntimeException(java.lang.String) [4]
9 athrow
Line numbers:
[pc: 0, line: 21]
Local variable table:
[pc: 0, pc: 10] local: this index: 0 type: android.content.ContextWrapper
[pc: 0, pc: 10] local: name index: 1 type: java.lang.String
[pc: 0, pc: 10] local: mode index: 2 type: int
答案 0 :(得分:1)
你做过m_cCursor.moveToFirst()
和m_cCursor.moveToNext()
吗?
答案 1 :(得分:0)
在
Cursor m_cCursor=context.getContentResolver().query(deleteUri, null, null, null, null);
添加
while (cur.moveToNext()) {
int m_cnum=m_cCursor.getCount();
int id =m_cCursor.getInt(0);
int thread_id = m_cCursor.getInt(1);
}