How to read SMS stored in SIM card in Android

青春壹個敷衍的年華 提交于 2019-12-14 04:14:11

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!