我可以在 Android 内部存储上创建文件夹吗?
假设我正在处理一个文本编辑器应用程序。我想将创建的文本文件存储在手机或 SD 卡中的文件夹中(由用户选择)。我只想将文件保存到内部存储(手机)上的文件夹中。我可以通过代码在 Android 内部存储上创建一个文件夹并将这些文件复制到那里吗?一个文件夹不会是我的应用程序私有的,也不会存储在“/data/data/MyapplicationPackage/”下,并且用户可以访问(读取)? 有什么提示吗?谢谢。
Assume I'm dealing with a text editor application. I want to store created text files on a folder which will be in the phone or sdcard (from user choice). I just want to save files onto a folder on internal storage(phone). Am i able to create a folder on android internal storage from code and copy these files there? A folder which will not be private to my application or store under "/data/data/MyapplicationPackage/" and witch from the user could access(read)?
Any hint? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
为了满足您的要求,您可以:
ACTION_SEND
,您可以让他们通过电子邮件发送导出的文件、保存到 Dropbox 等,几乎免费。To satisfy your requirement you can either:
ACTION_SEND
you can let them send the exported files by email, save to Dropbox, etc. practically for free.据我所知,可以,但不符合您的标准。
它将是私有的,存储在 /data/data/... 下,并且用户无法访问(除非通过应用程序)。除非用户已获得 root 权限。
As far as I know, you can, but it does not meet your criteria.
It will be private, stored under /data/data/..., and will not be user accessible except via the application. That is unless the user is rooted.
请查看此处。您有很多选项可以做到这一点,所有这些都取决于您设备上安装的名称。请参阅 API getDir() 来为私有文件创建文件路径。
还要检查录音机应用程序正在写入其文件的路径,这为我解决了问题,因为由于缺乏许可,我无法让任何私人文件工作。
您始终可以在控制台模式下输入 ADB,使用“adb shell”并运行 linux“mount”命令来查看所有已安装的文件,但您需要 root 访问权限。
Take a look in here. You have many options to do that, and all depends on mounted names on your device. See APIs getDir() to create a filepath for a private file.
Check also in which path the audio recorder application is writing its files, that solved for me since I could'nt get any private file working for lack of permitions.
You can always enter ADB in console mode, with "adb shell" and run a linux "mount" command to see all your mounted files, you'll need root access though.
我也面临着同样的问题。我想在内存中创建一个文件夹。我尝试了 stackoverflow 本身提供的许多代码。但这些都不能正常工作。所以最后我给了我自己的根目录。
这段代码对我来说工作得非常好。
I also was facing same problem. I wanted to create a folder in Internal Memory. I tried many code provided in stackoverflow itself. But non of those worked properly. So at last I gave the root directory own my own.
This code worked absolutely fine for me.