我们如何从收件箱中删除单个短信,我已尝试过下面的代码,但它仍然会删除所有内容。
Cursor c = getApplicationContext().getContentResolver().
query(Uri.parse("content://sms/sent"), new String[] { "_id", "thread_id", "address", "person","date", "body" }, null, null, null);
try {
while (c.moveToNext()) {
int id = c.getInt(0);
String address = c.getString(2);
if(address.equals(address)){
getApplicationContext().getContentResolver().delete(Uri.parse("content://sms/" + id),null, null);}
}
}catch(Exception e){
}
答案 0 :(得分:0)
@ user3739864试试这个;
try {
while (c.moveToNext()) {
int id = c.getInt(0);
String address = c.getString(2);
if(id == // the id you want to delete ){
getApplicationContext().getContentResolver().delete(Uri.parse("content://sms/" + id),null, null);}
}
} catch(Exception e){
}