我从我的应用发送短信。我想从“发件箱”中删除发送短信,因为短信包含访问密码的PIN码。短信发送,但删除不起作用。 短信exixst,因为我能够在“Cursor c_sms”中读取它
private void sms_sender(String sms_no, String sms_text) {
SmsManager.getDefault().sendTextMessage(sms_no, null, sms_text, null, null);
Toast
.makeText(MainScreen.this, R.string.text_message, Toast.LENGTH_SHORT)
.show();
Cursor c_sms = getApplicationContext().getContentResolver().query(Uri.parse("content://sms/"), null, null, null, null);
try{
while(c_sms.moveToNext()) {
long id = c_sms.getLong(0);
String pid = c_sms.getString(0);
String address = c_sms.getString(2);
if (address.equals(address)){
int count = getContentResolver().delete(Uri.parse("content://sms/" + id),null,null);
}
}
}
catch (Exception e){
Toast
.makeText(MainScreen.this, R.string.text_error + e.toString(), Toast.LENGTH_LONG)
.show();
}
}
答案 0 :(得分:-1)
getContentResolver()。delete(Uri.parse(“content:// sms / sent”),“address =?and body =?”,new String [] {etsendernumber.getText()。toString(),etmessagebody 。.getText()的toString()});
使用此代码