Android - 拉取 SQlite 数据库 android 设备 [英] Android - Pulling SQlite database android device

查看:31
本文介绍了Android - 拉取 SQlite 数据库 android 设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我到处寻找,但找不到真正准确的答案或有关如何(如果可能)执行此操作的教程.

I've looked everywhere and i can't find a real precise answer or a tutorial on how, if it is possible, to do this.

是否可以以任何方式提取 Android 设备的数据库而无需 root?我只需要以任何方式提取该数据即可在我的电脑上收集它,那么我该如何执行呢?我是否必须重新编程应用程序或你们知道的任何方法,但请记住不要植根设备.谢谢

is it possible to pull in any way a database of an Android device without having to root it? i just need to extract that data in any way in order to gather it on my pc, so how can i perform this? do i have to reprogram the app or whatever method you guys know about, but remember without rooting the device. thanks

推荐答案

实现所需的常用方法是使用 ADB pull 命令.

A common way to achieve what you desire is to use the ADB pull command.

大多数情况下我更喜欢的另一种方式是通过代码将数据库复制到 SD 卡:

Another way I prefer in most cases is to copy the database by code to SD card:

try {
    File sd = Environment.getExternalStorageDirectory();

    if (sd.canWrite()) {
        String currentDBPath = "/data/data/" + getPackageName() + "/databases/yourdatabasename";
        String backupDBPath = "backupname.db";
        File currentDB = new File(currentDBPath);
        File backupDB = new File(sd, backupDBPath);

        if (currentDB.exists()) {
            FileChannel src = new FileInputStream(currentDB).getChannel();
            FileChannel dst = new FileOutputStream(backupDB).getChannel();
            dst.transferFrom(src, 0, src.size());
            src.close();
            dst.close();
        }
    }
} catch (Exception e) {

}

不要忘记在清单中设置写入 SD 的权限,如下所示.

Don't forget to set the permission to write on SD in your manifest, like below.

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

这篇关于Android - 拉取 SQlite 数据库 android 设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆