Developer Andrey Yefimov has a blog post up where he demonstrates how to read a list of SMS messages into Delphi XE6 Firemonkey using the Android API. We’ve covered reading and writing SMS messages on Android before a few months ago. Andrey explains that you need to add the Read SMS permission to your Android manifest for in order for your app to read SMS messages. He also explains that SMS messages are stored in directories on your Android device using local databases. There is sample code where he shows how to find and read these files using the Android SDK and the Delphi Firemonkey JNI. The demo app includes a list of URIs (like content://sms) to the location of the SMS messages and the source code resolves the URI to the actual location. The code then loops through the location using a JCursor object and read each item like so: JStringToString(cursor.getString(

cursor.getColumnIndex(StringToJString(‘ADDRESS’)))); I think you can see a list of all of the columns in this Object Pascal Android interface file:

TJTelephony_TextBasedSmsColumnsMESSAGE_TYPE_ALL = 0; TJTelephony_TextBasedSmsColumnsMESSAGE_TYPE_INBOX = 1; TJTelephony_TextBasedSmsColumnsMESSAGE_TYPE_SENT = 2; TJTelephony_TextBasedSmsColumnsMESSAGE_TYPE_DRAFT = 3; TJTelephony_TextBasedSmsColumnsMESSAGE_TYPE_OUTBOX = 4; TJTelephony_TextBasedSmsColumnsMESSAGE_TYPE_FAILED = 5; TJTelephony_TextBasedSmsColumnsMESSAGE_TYPE_QUEUED = 6; TJTelephony_TextBasedSmsColumnsTYPE = 'type'; TJTelephony_TextBasedSmsColumnsTHREAD_ID = 'thread_id'; TJTelephony_TextBasedSmsColumnsADDRESS = 'address'; TJTelephony_TextBasedSmsColumnsDATE = 'date'; TJTelephony_TextBasedSmsColumnsDATE_SENT = 'date_sent'; TJTelephony_TextBasedSmsColumnsREAD = 'read'; TJTelephony_TextBasedSmsColumnsSEEN = 'seen'; TJTelephony_TextBasedSmsColumnsSTATUS = 'status'; TJTelephony_TextBasedSmsColumnsSTATUS_NONE = -1; TJTelephony_TextBasedSmsColumnsSTATUS_COMPLETE = 0; TJTelephony_TextBasedSmsColumnsSTATUS_PENDING = 32; TJTelephony_TextBasedSmsColumnsSTATUS_FAILED = 64; TJTelephony_TextBasedSmsColumnsSUBJECT = 'subject'; TJTelephony_TextBasedSmsColumnsBODY = 'body'; TJTelephony_TextBasedSmsColumnsPERSON = 'person'; TJTelephony_TextBasedSmsColumnsPROTOCOL = 'protocol'; TJTelephony_TextBasedSmsColumnsREPLY_PATH_PRESENT = 'reply_path_present'; TJTelephony_TextBasedSmsColumnsSERVICE_CENTER = 'service_center'; TJTelephony_TextBasedSmsColumnsLOCKED = 'locked'; TJTelephony_TextBasedSmsColumnsERROR_CODE = 'error_code'; 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 TJTelephony_TextBasedSmsColumnsMESSAGE_TYPE_ALL = 0 ; TJTelephony_TextBasedSmsColumnsMESSAGE_TYPE_INBOX = 1 ; TJTelephony_TextBasedSmsColumnsMESSAGE_TYPE_SENT = 2 ; TJTelephony_TextBasedSmsColumnsMESSAGE_TYPE_DRAFT = 3 ; TJTelephony_TextBasedSmsColumnsMESSAGE_TYPE_OUTBOX = 4 ; TJTelephony_TextBasedSmsColumnsMESSAGE_TYPE_FAILED = 5 ; TJTelephony_TextBasedSmsColumnsMESSAGE_TYPE_QUEUED = 6 ; TJTelephony_TextBasedSmsColumnsTYPE = 'type' ; TJTelephony_TextBasedSmsColumnsTHREAD_ID = 'thread_id' ; TJTelephony_TextBasedSmsColumnsADDRESS = 'address' ; TJTelephony_TextBasedSmsColumnsDATE = 'date' ; TJTelephony_TextBasedSmsColumnsDATE_SENT = 'date_sent' ; TJTelephony_TextBasedSmsColumnsREAD = 'read' ; TJTelephony_TextBasedSmsColumnsSEEN = 'seen' ; TJTelephony_TextBasedSmsColumnsSTATUS = 'status' ; TJTelephony_TextBasedSmsColumnsSTATUS_NONE = - 1 ; TJTelephony_TextBasedSmsColumnsSTATUS_COMPLETE = 0 ; TJTelephony_TextBasedSmsColumnsSTATUS_PENDING = 32 ; TJTelephony_TextBasedSmsColumnsSTATUS_FAILED = 64 ; TJTelephony_TextBasedSmsColumnsSUBJECT = 'subject' ; TJTelephony_TextBasedSmsColumnsBODY = 'body' ; TJTelephony_TextBasedSmsColumnsPERSON = 'person' ; TJTelephony_TextBasedSmsColumnsPROTOCOL = 'protocol' ; TJTelephony_TextBasedSmsColumnsREPLY_PATH_PRESENT = 'reply_path_present' ; TJTelephony_TextBasedSmsColumnsSERVICE_CENTER = 'service_center' ; TJTelephony_TextBasedSmsColumnsLOCKED = 'locked' ; TJTelephony_TextBasedSmsColumnsERROR_CODE = 'error_code' ;

Andrey’s blog is in Russian but you should be able to use Google Chrome to translate it to your language.

Head over and check out the full blog post for yourself about how to read SMS messages with Delphi XE6 Firemonkey.

Or download a mirror of the Read SMS demo for Delphi XE6 Firemonkey