【发布时间】:2014-07-02 05:09:26
【问题描述】:
我们如何从收件箱中删除一条短信,我尝试了下面的代码,但它仍然全部删除。
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){
}
【问题讨论】:
-
看看你的 if 条件,你匹配的地址和你从光标处得到的地址是一样的。
-
那怎么办只能删除一条短信。