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.

*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
===== Running Test ======
service_center_address: +44780xxxxxxxxxxx
address: +44770xxxxxx
message_class: UNKNOWN
body: Test 1
date: 1519562531000
status: -1
index_on_icc: 1
is_status_report: false
transport_type: sms
type: 0
locked: 0
error_code: 0
_id: 0
service_center_address: +44780xxxxxxxx
address: +447704xxxxxxxx
message_class: UNKNOWN
body: Test 3
date: 1519563231000
status: -1
index_on_icc: 2
is_status_report: false
transport_type: sms
type: 0
locked: 0
error_code: 0
_id: 1
====== Test completed=========
 
Upvote 0
Top