3

我正在尝试通过我的应用程序从设备中删除所有 SMS 消息,但由于某些原因,SMS 日志仍然出现在某些三星设备的通话记录中。

我尝试了一种更“激进”的方法,并使用以下 URI 删除了ContentResolver

  • content://call_log/calls
  • content://sms
  • content://sms/inbox
  • content://sms/sent
  • content://mms/inbox
  • content://mms
  • content://mms-sms
  • content://mms/address
  • content://mms/part
  • content://mms/sent
  • content://mms/outbox

使用以下简单代码完成删除:

ContentResolver cr = mContext.getContentResolver() ;
cr.delete(uri, null, null) ;

结果是所有短信都从设备中删除,通话记录从通话中清除,但仍然包含短信日志(对于不存在的短信)。

上面提到的所有表在过程结束时确实是空的,但我找不到呼叫日志从中获取其 SMS 数据的相关来源。

我找到了有关该主题的以下帖子,但仍然没有有效的解决方案:

我会提前声明,我知道 .. 处的“logtype”列CallLog.Calls.CONTENT_URI。不相关,因为该表现在是空的,并且数据不是来自那里。

4

3 回答 3

2

找到了答案——

为了访问三星通话记录,我们需要在清单中添加几个权限:

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

现在,我们要做的就是使用内容解析器从 content://logs/historys 中删除日志类型 400、410、700、200、300、600 和 500,如下所示:

    mContext = getActivity(); // Assuming that you are doing this from within a Fragment

    try
    {
        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(Exception exception)
    {
        exception.printStackTrace();
    }

对我来说就像一个魅力。

于 2014-06-18T13:13:39.853 回答
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...

于 2013-09-17T07:12:12.090 回答
0

三星为消息日志使用单独的存储空间。尽管如此,他们还是创建了一个特殊的 ContentProvider 来访问它们。源我还没有找到,但找到了 URI: content://logs/historys

删除指定编号的日志示例:

try{
    context.getContentResolver().delete(Uri.parse("content://logs/historys"), CallLog.Calls.NUMBER + " like '%" + number + "'", null);
} catch (IllegalArgumentException e){
    //that mean this not samsung device
}
于 2014-04-18T11:40:48.937 回答