问题
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.
回答1:
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
来源:https://stackoverflow.com/questions/33854308/how-to-read-sms-stored-in-sim-card-in-android