Sub chiamajava
Dim messaggio As String="Test"
Dim numero As String="+3934XXXXXXX"
native.RunMethod("deleteSMS",Array(messaggio, numero))
End Sub
#if JAVA
import android.net.Uri;
import android.database.Cursor;
import anywheresoftware.b4a.keywords.Common;
public void deleteSMS( String message, String number) {
Common.Log("Messaggio:" + message);
Common.Log("Numero:" + number);
Uri uriSms = Uri.parse("content://sms");
Cursor c = processBA.context.getContentResolver().query(uriSms, new String[] { "_id", "thread_id", "address", "person", "date", "body" }, null, null, null);
if(c==null)
{
return;
}
c.moveToFirst();
do {
long id = c.getLong(0);
long threadId = c.getLong(1);
String address = c.getString(2);
String body = c.getString(5);
String date = c.getString(3);
Common.Log(address);
Common.Log(body);
if (message.equals(body) && address.equals(number)) {
Common.Log("Deleting SMS with id: " + threadId);
int rows = processBA.context.getContentResolver().delete(Uri.parse("content://sms/" + id), "date=?",new String[] { c.getString(4) });
}
} while (c.moveToNext());
}
#End If