简体   繁体   中英

How to read SMS stored in SIM card in Android

I was wondering if anyone knew anything about programmatically getting the SMS messages off of your phone's sim card on an android platform.

I would like to write a program that allows you to save either individual messages or entire threads to the SD card, but after looking around for a bit, I have discovered that google decided to take out that api from the current android SDK.

I saw in a few places that there are hidden APIs for this, but no one knew what they were or how to use them.

You can manage the SMS saved on the SIM card with the URI content://sms/icc . It works also with the last version of Android.

For example this prints the contents of the cursor to System.out :

Cursor cursor = getContentResolver().query(Uri.parse("content://sms/icc"), null, null, null, null);
DatabaseUtils.dumpCursor(cursor);

You need the permissions:

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

You can find a complete example here: https://github.com/android/platform_packages_apps_mms/blob/master/src/com/android/mms/ui/ManageSimMessages.java

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM