Android Question Read SMS messages stored on SIM card

Derek Johnson

Active Member
Licensed User
Longtime User
Is there a way of reading SMS messages that stored on the SIM card (rather than the phone)? When I connect my phone via Bluetooth in the car, any SMS messages received get put on the SIM card instead of the phone. I was wondering there was a way of reading them using any of the libraries?

Just thinking round this, perhaps it would be easier to create an App that intercepts all the SMS messages, and then only does something special when a BlueTooth device is linked to the phone..I could perhaps use the technique described in https://www.b4x.com/android/forum/t...cepting-sms-messages-in-the-background.20103/


Derek
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
What is the output of this code:
B4X:
Dim cr As ContentResolver
cr.Initialize("cr")
Dim uri As Uri
uri.Parse("content://sms/icc")
Dim rs As ResultSet = cr.Query(uri, Null, "", Null, "")
Do While rs.NextRow
   For c = 0 To rs.ColumnCount - 1
       Log(rs.GetColumnName(c) & ": " & rs.GetString2(c))
   Next
Loop
rs.Close
Depends on ContentResolver and SQL libraries.

Add to the manifest editor:
B4X:
AddPermission(android.permission.READ_SMS)
AddPermission(android.permission.WRITE_SMS)
 
Upvote 0

Derek Johnson

Active Member
Licensed User
Longtime User
Perfect thank you.

 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…