在设备根接取文件文件、设备

2023-09-06 05:31:19 作者:怪我爱的太狂野

我在开发Galaxy Tab的应用程序,现在我需要获得有关/数据的一些文件/数据//文件夹中。

I'm developing an application for Galaxy Tab, and now I need get some files on the /data/data// folder.

模拟器是真的,真的很慢。所以,我测试的设备,并且需要从设备获取文件(从模拟器我能够做到)。我该怎么做?

The emulator is really, really slow. So I'm testing on device, and need get the files from device (from emulator i'm able to do). How can I do that?

推荐答案

在您的code,从保护的文件夹所需的文件复制到手机的SD卡添加调试功能。然后,您可以从您的电脑访问它们。

Add a debug function in your code to copy the required files from the protected folders onto your phone's SD card. You can then access them from your PC.

public static void backupFile() throws IOException {

  String inFileName = "/data/data/your.package.name/........"; //TODO Use folder/filename
  File inFile = new File(inFileName);
  FileInputStream fis = new FileInputStream(inFile);

  String outFileName = Environment.getExternalStorageDirectory()+"/........"; //TODO Use output filename
  OutputStream output = new FileOutputStream(outFileName);

  byte[] buffer = new byte[1024];
  int length;
  while ((length = fis.read(buffer))>0)
    output.write(buffer, 0, length);

  output.flush();
  output.close();
  fis.close();
}