【问题标题】:Accessing DATABASE from real android device, Not rooted (samsung s4)从真正的android设备访问数据库,没有root(samsung s4)
【发布时间】:2014-11-29 23:30:16
【问题描述】:

我正在尝试从真正的 android 设备读取我的数据库文件 mydatabase.db,但是当我尝试打开我的数据库文件时进入所有目录后,每次找不到该文件时都会出错。请提出好的解决方案。提前致谢。

数据库包名称 = com.example.databasedemo 数据库文件名=mydatabase.db

G:>cd adt-bundle-windows-64\adt-bundle-windows-x86_64-20140702\sdk\platform-too ls

G:\adt-bundle-windows-64\adt-bundle-windows-x86_64-20140702\sdk\platform-tools>a
db -d shell
shell@ks01lte:/ $ cd data/data
cd data/data
shell@ks01lte:/data/data $ cd com.example.databasedemo
cd com.example.databasedemo
shell@ks01lte:/data/data/com.example.databasedemo $ cd databases
cd databases
shell@ks01lte:/data/data/com.example.databasedemo/databases $ ls
ls
opendir failed, Permission denied
255|shell@ks01lte:/data/data/com.example.databasedemo/databases $

【问题讨论】:

  • 也许你可以告诉我们你在做什么
  • 如果您尝试访问system/data/app 中的数据库 - 这是不可能的
  • G:\>cd adt-bundle-windows-64\adt-bundle-windows-x86_64-20140702\sdk\platform-too ls G:\adt-bundle-windows-64\adt- bundle-windows-x86_64-20140702\sdk\platform-tools>a db -d shell shell@ks01lte:/ $ cd data/data cd data/data shell@ks01lte:/data/data $ cd com.example.databasedemo cd com .example.databasedemo shell@ks01lte:/data/data/com.example.databasedemo $ cd databases cd databases shell@ks01lte:/data/data/com.example.databasedemo/databases $ ls ls opendir failed, Permission denied 255|shell @ks01lte:/data/data/com.example.databasedemo/databases $

标签: android shell


【解决方案1】:

可以通过 adb:

adb -d shell 'run-as com.your.package cat /data/data/com.your.package/databases/dbname.sqlite > /sdcard/dbname.sqlite'
adb pull /mnt/sdcard/dbname.sqlite

【讨论】:

  • 嗨彼得,谢谢你,但它不能工作..我也应该使用逗号('')吗? cat 有什么用? .. 谢谢
  • 一个无根的 android 设备,您只能使用带有您的包名称的 run-as 命令导航到数据文件夹(包含数据库)。因此,您必须将数据库文件复制到 sdcard(cat 命令),然后您可以通过大容量存储读取 sdcard 或使用 adb pull 来获取您的数据库。
  • Microsoft Windows [版本 6.2.9200] (c) 2012 Microsoft Corporation。版权所有。 C:\Users\Deepinder>g:G:\>cd adt-bundle-windows-64\adt-bundle-windows-x86_64-20140702\sdk\platform-too ls G:\adt-bundle-windows-64\adt -bundle-windows-x86_64-20140702\sdk\platform-tools>a db -d shell 'run-as com.example.databasedemo cat /data/data/com.example.database demo/databases/mydatabase.sqlite > /sdcard /mydatabse.sqlite' 系统找不到指定的路径。
  • 感谢 Petr,但仍然出现错误。我正在做任何错误
  • 试试 mydatabase.db .. 也许你可以试试其他方法:stackoverflow.com/a/18472135/3080479
猜你喜欢
  • 2015-07-13
  • 2019-12-09
  • 2019-01-23
  • 2015-04-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多