在设备根接取文件 [英] Acess files on root in device

查看:125
本文介绍了在设备根接取文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在开发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();
}

这篇关于在设备根接取文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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