Android将文件写入Windows USB文件传输的可访问文件夹 [英] Android Write file to accessible folder for windows usb file transfer

查看:253
本文介绍了Android将文件写入Windows USB文件传输的可访问文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用标准Nexus 5进行操作,而Nexus 5未根植于标准香草android 4.4.2

I am operating with a standard Nexus 5 which is un-rooted with standard vanilla android 4.4.2

我想创建一个新文件,该文件可在Windows中通过标准USB连接器访问.我不想植根我的手机.

I would like to create a new file that is accessible in Windows through the standard USB connector. I don't want to root my phone.

这是我的代码段:

File outputFile = new File(new File(getFilesDir().getParentFile(), "assets"), "example.xml");

有人知道通过USB传输可在应用+中写入的任何目录吗?

Does anyone know of any directories that are writable in app + readable via USB transfer ?

谢谢您的帮助! :)

推荐答案

您可以像这样在外部存储设备上创建文件:

You can create the file on the External Storage like this:

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文件传输的可访问文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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