I wanna delete ALL the messages in my Messaging with just one click on the button. But I already tried the coding below, it is not working... Can someone just help me to achieve this? Thanks...
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);
}
}
}
What should I add in Manifest? Having force close when testing with my Galaxy Tab 2