为什么第一条短信不能在短信界面立即删除,而非要重新进入才显示删除,而其他短信都能在界面上立即删除,并且删除的短信只能按发送的顺序删除?
这是删除信息的源码:
try {
String nei=tvText.getText().toString();
ContentValues values = new ContentValues();
values.put("body", nei);
ContentResolver CR = ctx.getContentResolver();
// Query SMS
Uri uriSms = Uri.parse("content://sms/sent");
Cursor c = CR.query(uriSms,
new String[] { "_id" }, null, null, null);
if (c.moveToFirst()) {
// Delete SMS
//long threadId =c.getLong(1);
int id = c.getInt(c.getColumnIndex("_id"));
CR.delete(Uri.parse("content://sms"),
"_id=" + id, null);
int ids = c.getInt(c.getColumnIndex("_id"));
CR.delete(Uri.parse("content://sms" ), "_id=" + ids, null);
}
c.close();
// ctx.getContentResolver().update(Uri.parse("content://sms"), values, "thread_id = " + thread, null);
//init(thread);
} catch (Exception e) {
Log.d("deleteSMS", "Exception:: " + e);
}
这是删除信息的源码:
try {
String nei=tvText.getText().toString();
ContentValues values = new ContentValues();
values.put("body", nei);
ContentResolver CR = ctx.getContentResolver();
// Query SMS
Uri uriSms = Uri.parse("content://sms/sent");
Cursor c = CR.query(uriSms,
new String[] { "_id" }, null, null, null);
if (c.moveToFirst()) {
// Delete SMS
//long threadId =c.getLong(1);
int id = c.getInt(c.getColumnIndex("_id"));
CR.delete(Uri.parse("content://sms"),
"_id=" + id, null);
int ids = c.getInt(c.getColumnIndex("_id"));
CR.delete(Uri.parse("content://sms" ), "_id=" + ids, null);
}
c.close();
// ctx.getContentResolver().update(Uri.parse("content://sms"), values, "thread_id = " + thread, null);
//init(thread);
} catch (Exception e) {
Log.d("deleteSMS", "Exception:: " + e);
}