Good morning everyone,
I'm doing an app in Android Studio that exchanges SMS, but I would like it to read the message and automatically delete it in the SMS tray received.
I use the following code but it does not work for me:
Cursor cur = context.getContentResolver().query(Uri.parse("content:
//sms/inbox"), null, null, null, null);
if (cur.moveToFirst()) {
do {
int indexBody = cur.getColumnIndex("body");
int indexId = cur.getColumnIndex("_id");
if (mensaje.equals(cur.getString(indexBody))) {
String uri = "content://sms/inbox" + cur.getInt(indexId);
context.getContentResolver().delete(Uri.parse(uri), null, null);
}
} while (cur.moveToNext());
}
The message variable read it correctly before.
Also, I have all the permissions in the manifest and accepted in the mobile.
You know I can be doing wrong.