我正在开发一个应用程序,我知道我的数据库*.db将出现在data/data/com.****.***
我可以在sqlite管理器的帮助下从Eclipse中的AVD访问这个文件
但是我的安卓手机无法访问这个文件。 我谷歌了一下,它说我需要在我的手机上查找,但我不想这样做。
我如何访问我的data/data/.....目录在我的安卓手机“没有根它”?
是否可以更改目录data/data.....的用户权限没有生根?
我正在开发一个应用程序,我知道我的数据库*.db将出现在data/data/com.****.***
我可以在sqlite管理器的帮助下从Eclipse中的AVD访问这个文件
但是我的安卓手机无法访问这个文件。 我谷歌了一下,它说我需要在我的手机上查找,但我不想这样做。
我如何访问我的data/data/.....目录在我的安卓手机“没有根它”?
是否可以更改目录data/data.....的用户权限没有生根?
当前回答
adb backup didn't work for me, so here's what I did (Xiaomi Redmi Note 4X, Android 6.0): 1. Go to Settings > Additional Settings > Backup & reset > Local backups. 2. Tap 'Back up' on the bottom of the screen. 3. Uncheck 'System' and 'Apps' checkmarks. 4. Tap detail disclosure button on the right of the 'Apps' cell to navigate to app selection screen. 5. Select the desired app and tap OK. 6. After the backup was completed, the actual file need to be located somehow. Mine could be found at /MIUI/backup/AllBackup/_FOLDER_NAMED_AFTER_BACKUP_CREATION_DATE_. 7. Then I followed the steps from this answer by RonTLV to actually convert the backup file (.bak in my case) to tar (duplicating from the original answer): " a) Go here and download: https://sourceforge.net/projects/adbextractor/ b) Extract the downloaded file and navigate to folder where you extracted. c) run this with your own file names: java -jar abe.jar unpack c:\Intel\xxx.ab c:\Intel\xxx.tar "
其他回答
要做到以上任何一项(即从手机本身访问受保护的文件夹),你仍然需要root。(这包括更改/data文件夹的挂载权限并访问它)
如果没有root,除了通过代码从应用程序内部读取外,直接访问/数据是不可能的。所以你可以试着把那个文件复制到sdcard或者其他可以访问的地方,然后,你就可以正常访问它了。
如果您使用的是开发人员设备,那么root不会使您的保修失效。对不起,我没有别的办法了。
使用eclipse中的文件资源管理器。Select Windows => Show View => Other…>文件资源管理器。
另一种方法是通过adb提取文件:
adb pull /system/data/data/<yourpackagename>/databases/<databasename> /sdcard
我也曾经遇到过同样的问题。除了adb shell或根设备,没有办法在android设备中直接访问文件。
下面是02种替代方案:
1)
public void exportDatabse(String databaseName)
{
try {
File sd = Environment.getExternalStorageDirectory();
File data = Environment.getDataDirectory();
if (sd.canWrite()) {
String currentDBPath = "//data//"+getPackageName()+"//databases//"+databaseName+"";
String backupDBPath = "backupname.db";
File currentDB = new File(data, 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) {
}
}
2)试试这个:https://github.com/sanathp/DatabaseManager_For_Android
你也可以尝试使用根资源管理器应用程序获取db。如果这不起作用,那么你可以试试这个:
打开cmd 改变目录,进入“平台工具” 类型为“adb shell” 苏 在设备上按“允许” chmod 777 /数据/数据/数据/数据/数据/ com.application。包/数据/数据/ com.application.package / * 在Eclipse中打开DDMS视图,然后从那里打开“FileExplorer”以获得所需的文件
在此之后,您应该能够浏览根设备上的文件。
如果你使用的是Android Studio 3.0或更高版本,请遵循以下步骤。
单击“查看>工具Windows >设备文件资源管理器”。 展开/data/data/[package-name]节点。
只能展开在非根设备上以调试模式运行的包。