Skip to content

Instantly share code, notes, and snippets.

@sensoft2207
Created June 21, 2019 03:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sensoft2207/318d5bd3e7c4787a765e993ef18cd79d to your computer and use it in GitHub Desktop.
Save sensoft2207/318d5bd3e7c4787a765e993ef18cd79d to your computer and use it in GitHub Desktop.
private void removeMessage(Context context, String fromAddress) {
Uri uriSMS = Uri.parse("content://sms/inbox");
Cursor cursor = context.getContentResolver().query(uriSMS, null,
null, null, null);
cursor.moveToFirst();
if(cursor.getCount() > 0){
int ThreadId = cursor.getInt(1);
Log.d("Thread Id", ThreadId+" id - "+cursor.getInt(0));
Log.d("contact number", cursor.getString(2));
Log.d("column name", cursor.getColumnName(2));
context.getContentResolver().delete(Uri.
parse("content://sms/conversations/"+ThreadId), "address=?",
new String[]{fromAddress});
Log.d("Message Thread Deleted", fromAddress);
}
cursor.close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment