我使用的是标准 Nexus 5,该设备未使用标准 vanilla android 4.4.2 进行 root 操作
我想创建一个可在 Windows 中通过标准 USB 连接器访问的新文件。我不想root我的手机。
这是我的代码 fragment :
File outputFile = new File(new File(getFilesDir().getParentFile(), "assets"), "example.xml");
有人知道有哪些目录可以在应用程序中写入+通过 USB 传输读取吗?
感谢您的帮助! :)
最佳答案
您可以像这样在外部存储上创建文件:
String fileName = "example.xml";
String myDirectory = "myDirectory";
String externalStorage = Environment.getExternalStorageDirectory().getAbsolutePath();
File outputFile = new File(externalStorage + File.separator + myDirectory + File.separator + fileName);
关于Android 将文件写入可访问文件夹以进行 Windows USB 文件传输,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22304173/