Android 将文件写入可访问文件夹以进行 Windows USB 文件传输

标签 android windows file-io file-transfer

我使用的是标准 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/

相关文章:

android - 动态加载使用资源的apk

c - 将文本写入 C : Ctrl + D doesn't work on Windows 中的文件

windows - Qt + 声子 : doesn't play on some computers

c++ - 打开文件名 : Setting lpstrTitle via converted string doesn't work; outputs lots of 'Ì' s and other special characters

Python:将值读入空数组,然后返回文件

java - 在 Java 中使用并发在磁盘上创建键值存储

javascript - 动态创建文件输入元素

Javascript 引用错误 : Security violation on Android Opera

android - 在默认位置启动 Google MapView

android - Spinner 下拉项目彩色背景的波纹效果 (appcompat-v7 V21)