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

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

问题描述

我到处找,我无法找到一个真正的precise答案或者怎么样,如果可能的话,要做到这一点的教程。

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设备的数据库,而不必根呢?我只需要提取数据以任何方式,以收集它在我的电脑,所以我怎么能执行呢?我一定要重新编程的应用程序或任何方法,你们知道的,但要记住没有生根的设备。谢谢

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

推荐答案

要实现你的愿望的一种常用方法是使用亚行拉命令。

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

另一种方式我prefere在大多数情况下是code复制数据库到SD卡:

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

try {
                    File sd = Environment.getExternalStorageDirectory();
                    File data = Environment.getDataDirectory();

                    if (sd.canWrite()) {
                        String currentDBPath = "/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权限。

Dont forget to set the permission to write on SD in your manifest.

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

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