Android Deleting Sent SMS

2019-08-06 06:38发布

问题:

 int rsRem = cntentRes.delete(Uri.parse("content://sms/"), "address=\"9xxxx9x9xx9x9\"", null);

Above line of code is not working In rsRem receiving 0 (zero) after line execution...

I am using Samsung core II to testing app having this code I am using following permissions

<uses-permission android:name="android.permission.READ_SMS"/>
    <uses-permission android:name="android.permission.RECEIVE_SMS"/>
    <uses-permission android:name="android.permission.SEND_SMS"/>
    <uses-permission android:name="android.permission.WRITE_SMS" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_USER_DICTIONARY"/>
    <uses-permission android:name="android.permission.WRITE_USER_DICTIONARY" />

回答1:

Please consider that you can't delete SMS messages on devices with Android 4.4.

Also, the system now allows only the default app to write message data to the provider, although other apps can read at any time.

http://developer.android.com/about/versions/kitkat.html

No exception will be thrown if you try;

Source >> https://stackoverflow.com/a/19998937/519718



回答2:

As you know you can't delete SMS on devices with Android 4.4 or above. Acording to this:

Along with the new provider and APIs, Android 4.4 introduces new semantics for receiving messages and writing to the provider. When a message is received, the system routes it directly to the user's default messaging app using the new SMS_DELIVER intent. Other apps can still listen for incoming messages using the SMS_RECEIVED intent. Also, the system now allows only the default app to write message data to the provider, although other apps can read at any time. Apps that are not the user's default can still send messages — the system handles writing those messages to the provider on behalf of the app, so that users can see them in the default app.



标签: android sms