如何在Android设备中访问数据/数据文件夹?

本文翻译自:How to access data/data folder in Android device?

I am developing an app and I know my database *.db will appear in data/data/com.****.*** 我正在开发一个应用程序,我知道我的数据库*.db将出现在data/data/com.****.***

I can access this file from AVD in Eclipse with help of sqlite manager 我可以在sqlite管理器的帮助下从Eclipse中的AVD访问此文件

But I can't access this file in my Android phone. 但是我无法在Android手机中访问此文件。
I google it and it says I need to root my phone to do it, but I don't want to do it. 我在Google上搜索了它,并说我需要扎根手机才能做到,但我不想这样做。 (New phone, warranty issues, and security issues) (新电话,保修问题和安全性问题)

So here is my question: How can I access my data/data/..... directory in my Android phone " without rooting it "? 所以这是我的问题:如何在“ 不植根 ”的情况下访问Android手机中的data/data/.....目录?

Can I change user permissions for the directory data/data..... without rooting it? 我可以更改目录data/data.....用户权限而无需root用户吗?


#1楼

参考:https://stackoom.com/question/Szxh/如何在Android设备中访问数据-数据文件夹


#2楼

To do any of the above (ie access protected folders from within your phone itself), you still need root. 要执行上述任何一项操作(即从手机内部访问受保护的文件夹),您仍然需要root用户。 (That includes changing mount-permissions on the /data folder and accessing it) (这包括更改/ data文件夹上的安装权限并访问它)

Without root, accessing the /data directly to read except from within your application via code isn't possible. 如果没有root用户,则无法通过代码直接访问/data进行读取, 除非从应用程序内部进行读取。 So you could try copying that file to sdcard or somewhere accessible, and then, you should be able to access it normally. 因此,您可以尝试将该文件复制到sdcard或可访问的位置,然后,您应该可以正常访问它。

Rooting won't void your warranty if you have a developer device. 如果您使用的是开发人员设备,则生根维护不会使您的保修无效。 I'm sorry, there isn't any other way AFAIK. 抱歉,AFAIK没有其他方法。


#3楼

Use File Explorer in eclipse. 在Eclipse中使用文件资源管理器。 Select Windows => Show View => Other ... => File Explorer. 选择Windows =>显示视图=>其他... =>文件资源管理器。

An another way is pull the file via adb: 另一种方法是通过adb拉文件:

adb pull /system/data/data/<yourpackagename>/databases/<databasename> /sdcard

#4楼

One of the simple way is to create your database on SD-Card. 一种简单的方法是在SD卡上创建数据库。 Because you cannot get access to your phone's data folder in internal memory, unless you root your phone. 因为您无法访问手机的数据文件夹,除非您为手机设置了根目录。 So why not simply create your database on SD-Card. 那么,为什么不简单地在SD卡上创建数据库。

Moreover, if you want, you may write some file copying-code to copy your existing database file (from internal memory) to external memory without requiring any root. 此外,如果需要,您可以编写一些文件复制代码,以将现有数据库文件(从内部存储器)复制到外部存储器,而无需任何root用户。


#5楼

You could also try fetching the db using root explorer app. 您也可以尝试使用root Explorer应用程序获取数据库。 And if that does not work then you can try this: 如果这不起作用,则可以尝试以下操作:

  1. Open cmd 打开cmd
  2. Change your directory and go into 'Platform tools' 更改目录并进入“平台工具”
  3. Type ' adb shell ' 输入' adb shell '
  4. su
  5. Press 'Allow' on device 在设备上按“允许”
  6. chmod 777 /data /data/data /data/data/com.application.package /data/data/com.application.package/*
  7. Open DDMS view in Eclipse and from there open 'FileExplorer' to get your desired file 在Eclipse中打开DDMS视图,然后从其中打开“ FileExplorer”以获取所需的文件

After this you should be able to browse the files on the rooted device. 之后,您应该能够浏览已root用户的设备上的文件。


#6楼

您可以将此db文件复制到eclipse Explorer中的某个位置(例如:sdcard或PC),并且可以使用sqlite访问和更新此db文件。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值