Skip to content Skip to sidebar Skip to footer

Can't Remove Sms Logs From Call Log On Samsung Devices

I'm trying to remove all SMS messages from the device via my app, but for some reason SMS logs still appear on the call log on some of the Samsung devices. I've tried a more 'radic

Solution 1:

The result was that all text messages are deleted from the device, call log is clear from calls, BUT still contains SMS logs (for SMS messages that does not exist).

what exactly your indication for "still contains SMS logs"? what contains SMS logs? I'll assume you refer to Samsung Phone calls app. if so - unfortunately, as @CommonsWare said, this phone calls app not necessarily displaying correct state of the database behind the relevant ContentProvider.

it might be that this app caching (persistent / not persistent) data, and not refreshes it when the "real data" (from content provider database) change.. who knows... maybe only if it process will restart, and it cache would clear - it would refresh itself...

Solution 2:

Found the answer -

In order to get access to Samsung call logs we need to add a couple of Permissions to the manifest:

<uses-permissionandroid:name="com.sec.android.provider.logsprovider.permission.READ_LOGS" /><uses-permissionandroid:name="com.sec.android.provider.logsprovider.permission.WRITE_LOGS" />

Now, all we have to do is to use the content resolver to delete log types 400, 410, 700, 200, 300, 600 and 500 from content://logs/historys as follows:

    mContext = getActivity(); // Assuming that you are doing this from within a Fragmenttry
    {
        mContext.getContentResolver().delete(Uri.parse("content://logs/historys"), "logtype='400'", null);
        mContext.getContentResolver().delete(Uri.parse("content://logs/historys"), "logtype='410'", null);
        mContext.getContentResolver().delete(Uri.parse("content://logs/historys"), "logtype='700'", null);
        mContext.getContentResolver().delete(Uri.parse("content://logs/historys"), "logtype='200'", null);
        mContext.getContentResolver().delete(Uri.parse("content://logs/historys"), "logtype='300'", null);
        mContext.getContentResolver().delete(Uri.parse("content://logs/historys"), "logtype='600'", null);
        mContext.getContentResolver().delete(Uri.parse("content://logs/historys"), "logtype='500'", null);
    }
    catch(Exceptionexception)
    {
        exception.printStackTrace();
    }

Worked like a charm for me.

Solution 3:

Samsung uses a separate storage for Messages log. Nevertheless, they have created a special ContentProvider to access them. Source I have not found, but found URI: content://logs/historys.

Example of removing log for specified number:

try{
    context.getContentResolver().delete(Uri.parse("content://logs/historys"), CallLog.Calls.NUMBER + " like '%" + number + "'", null);
} catch (IllegalArgumentException e){
    //that mean this not samsung device
}

Post a Comment for "Can't Remove Sms Logs From Call Log On Samsung Devices"