【问题标题】:Programmatically backup android call log and SMS without root privilege以编程方式备份​​ android 通话记录和短信,无需 root 权限
【发布时间】:2013-09-23 21:58:33
【问题描述】:

我只是想以编程方式备份​​我自己的 android 的 SMS 消息和通话记录(我想将其集成为更大的备份脚本的一部分)。有一个名为“短信备份和恢复”的用户应用程序可以做到这一点。 (如何让应用程序从 USB 接口运行?)

当我尝试时,

adb shell sqlite > dump

我收到permission denied。其他所有尝试读取数据库以访问这些日志的尝试,据我所知都在

data/data/com.sec.android.provider.logsprovider/databases/logs.db

遇到了permission denied

我读到的是,解决此权限问题的唯一方法是 root 设备,我目前不想这样做。

有没有办法通过 adb 做到这一点?如果必须,我不介意最终编写一个应用程序,但我想知道是否有更简单的方法。

【问题讨论】:

    标签: android sqlite backup adb


    【解决方案1】:

    您必须是 root 才能访问 /data/data 目录。如果没有 root,您可以编写一个程序来遍历 MMS-SMS 内容提供程序并将结果转储到您自己的数据库中(您可以导出/做任何您想做的事情)。

    这样的例子:

    try{
        Uri uri = Uri.parse("content://sms");
        ContentResolver contentResolver = getContentResolver();
        Cursor SMSL = contentResolver.query(uri, null, null, null, "date asc");
        while (SMSL.moveToNext()) {
            long dateTimeMillis = SMSL.getLong(SMSL.getColumnIndex("date"));
            Integer id1 = SMSL.getInt(SMSL.getColumnIndex("_id"));
            String body = SMSL.getString(SMSL.getColumnIndex("body"));
            Integer type1 = SMSL.getInt(SMSL.getColumnIndex("type"));
            String address = SMSL.getString(SMSL.getColumnIndex("address"));
            String read = SMSL.getString(SMSL.getColumnIndex("read"));
            String seen = SMSL.getString(SMSL.getColumnIndex("seen"));
    
                  //Do whatever with the data here 
    
            SMSL.close();   
            }       
    
            } catch (Exception e){
          e.printStackTrace();
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-05-24
      • 1970-01-01
      • 1970-01-01
      • 2019-07-01
      • 2019-11-29
      • 1970-01-01
      • 2019-04-23
      • 2019-05-30
      相关资源
      最近更新 更多