Created
June 21, 2019 03:45
-
-
Save sensoft2207/318d5bd3e7c4787a765e993ef18cd79d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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