Programmatically delete sms / message by sms id in android

How to delete all messages from android inbox or sent folders, without loop

How to get message ids

Use following simple function to delete sms from default android application / database.

[sociallocker]

public boolean deleteSms(String smsId) {
        boolean isSmsDeleted = false;
        try {
            mActivity.getContentResolver().delete(
                    Uri.parse("content://sms/" + smsId), null, null);
            isSmsDeleted = true;

        } catch (Exception ex) {
            isSmsDeleted = false;
        }
        return isSmsDeleted;
    }

[/sociallocker]

use this permission in AndroidManifiest

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

 

Leave a comment

Your email address will not be published. Required fields are marked *