Actually, I am interested in how to work with SMS in Android.

Specifically:

  1. Sending a message. When sending a message, is it programmatically recorded in the database?
  2. How to delete SMS from the table?
  3. How to edit SMS in database?

PS About the manifesto, permishennah not worth talking about. Specifically interested in the questions above.

    2 answers 2

    1) Programmatically sending a message (not via Intent ) is easy. Googling is easy - I will not even give a link. When sending to the database is not written - you need to do something like this:

     ContentValues values = new ContentValues(); values.put("address", "123456789"); values.put("body", "foo bar"); getContentResolver().insert(Uri.parse("content://sms/sent"), values); 

    2) Removing SMS from the database is also quite simple:

      activity.getContentResolver().delete(Uri.parse("content://sms/" + id), null, null); //id - идентификатор сообщения 

    3) Editing is identical. It is necessary to get a list of SMS, then on the id to pull out the desired, then write back.

    In the manifest, you need to keep a couple of permisens:

     <uses-permission android:name="android.permission.READ_SMS"/> <uses-permission android:name="android.permission.WRITE_SMS"/> 

    The most difficult part is intercepting incoming messages - there are many undocumented features. Only in KitKat there was official support for intercepting incoming messages.

    • It's not entirely clear where you got the address and body fields. What other fields can be filled? + where does the message id come from? Please attach snippet for reading SMS from the database. - Sergey Shustikov

    It is impossible to work with SMS in android, it seems that something appeared in API 19 but hardly. It is possible to read SMS through the hack, but not the fact that it will work on all devices.

    Protected by spirit community member 26 Jun '16 at 12:59 .

    Thank you for your interest in this issue. Since he collected a large number of low-quality and spam responses, which had to be deleted, now it’s necessary to have 10 reputation points on the site (the bonus for account association is not counted ).

    Maybe you want to answer one of the unanswered questions ?