Android Question Delete sent SMS messages

DonManfred

Expert
Licensed User
Longtime User
the 1st Link is most probably the right answer.
Only the default SMS App is allowed to do so.

For the how (if YOUR app is the default SMS app):
You then can probably do it using ContentResolver.

In my tutorial i am not using SMSses but i am talking about Calendars on the device and how to work with them using contentResolver.

As you can get SMS using ContentResolver i guess it should be possible then (your app is default and therefore you have writepermissions on the SMSProvider-Data) to remove them with ContentResolver too. You can find some imspiration (hopefully ;-)) in my Tutorial.
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Last edited:
Upvote 0

bokinet

Member
Licensed User
Thanks @DonManfred and @Star-Dust

Since I'm planning to use android device only for sending sms messages then putting B4A made app as default sms app isn't problem at all.

Is there any additional help how to in way of workflow and step by step since posts what I found and what you guys give me is a bit robust and not so self describing ones:

- to set B4A made app as SMS default app;

- to delete SMS messages after B4A app is set as default one;

Please keep in mind that I'm fresh and new with B4A and that if something is well explained for me isn't problem to integrate or to create.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
to set B4A made app as SMS default app
you need to define intent filters as described in the threads you linked.
your app must be seen when the deviceuser try to change the default sms app. I can´t really answer this as i did not tried this.

to delete SMS messages after B4A app is set as default one
As written above i would use ContentResolver for this. You can find the principle on how it works in my Calendar tutorial thread.

The principle to work with SMS-Database is the same. I´ve added Constants for SMS in my Library (see Tutorial. Version must be V0.12)

the base object which shows all constants to use with the SMS-Database is SMSConstants

B4X:
dim smsconst as SMSConstants
"CONTENT_URI" is the Uri you need to use with ContentResolver to query, update, delete anything from the Database.

Create a projection to READ SMSses. If you included the field ID in your projection you can get the ID of each SMS in the Queryresult. This ID you need to use when deleting using the ContentResolver.


Try to understand how it works with my Calendar-Examples. You need to build the same for the SMS-Database.

If you have any question/problem/error. Please create a new thread for any question.


The constants for the SMS-Database are

SMSConstants

  • Fields:
    • ADDRESS As String
    • BODY As String
    • CONTENT_URI As android.net.Uri
    • COUNT As String
    • CREATOR As String
    • DATE As String
    • DATE_SENT As String
    • DEFAULT_SORT_ORDER As String
    • ERROR_CODE As String
    • ID As String
    • LOCKED As String
    • MESSAGE_TYPE_ALL As Int
    • MESSAGE_TYPE_DRAFT As Int
    • MESSAGE_TYPE_FAILED As Int
    • MESSAGE_TYPE_INBOX As Int
    • MESSAGE_TYPE_OUTBOX As Int
    • MESSAGE_TYPE_QUEUED As Int
    • MESSAGE_TYPE_SENT As Int
    • PERSON As String
    • PROTOCOL As String
    • READ As String
    • REPLY_PATH_PRESENT As String
    • SEEN As String
    • SERVICE_CENTER As String
    • STATUS As String
    • STATUS_COMPLETE As Int
    • STATUS_FAILED As Int
    • STATUS_NONE As Int
    • STATUS_PENDING As Int
    • SUBJECT As String
    • SUBSCRIPTION_ID As String
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

bokinet

Member
Licensed User
Guys I understand what your telling me that Intent filters should be set.

That is 1st thing you should apply on B4A app and make B4A app default for SMS messaging.

And after that how to delete messages?

Let's pretend that we make intent filters and that B4A app is default app for SMS?

Android OS version 5+ solution.

Thanks for support and help!

(asking in opposite direction)
 
Upvote 0
Top