我想一键删除我的消息中的所有消息。但我已经尝试过下面的编码,它不起作用......有人可以帮我实现这个目标吗?谢谢...
public class DeleteSMSActivity extends Activity implements OnClickListener{
/** Called when the activity is first created. */
Button press;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
press = (Button)findViewById(R.id.button1);
press.setOnClickListener(this);
}
public void onClick(View view){
ContentResolver cr = getContentResolver();
Uri inboxUri = Uri.parse("content://sms/inbox");
Cursor c = cr.query(inboxUri , null, null, null, null);
while (c.moveToNext()) {
// Delete the SMS
String pid = c.getString(0); // Get id;
String uri = "content://sms/" + pid;
cr.delete(Uri.parse(uri), null, null);
}
}
}
我应该在清单中添加什么?使用我的 Galaxy Tab 2 进行测试时强制关闭