问题描述
所以我想保存在Android上的外部存储一些数据。我已经看了看哪里是说 getExternalStoragePublicDirectory(字符串型)
的API
如果有必要这个方法将创建相应的目录。
这些都是缺省目录:音乐,播客,铃声,报警,通知,图片,电影,下载。所以我的问题是:
- 如何创建我自己的? 的新目录
- 我怎样才能使它对用户不可见?这样用户就不会感到失望,其中额外的文件夹中。
您可以用coder_For_Life22的回答关于创建的文件夹,然后使其更看不见的用户,你可以做到以下几点:
- 将它命名为开始点。例如.yourappname
- 把一个空文件.nomedia到你的文件夹中。这$ P $记录从该文件夹,你有文件pvents媒体扫描仪。
So I would like to save some data on external storage on android. And I have looked at the the api where is says getExternalStoragePublicDirectory(String type)
"This method will create the appropriate directory if necessary."These are the default directories: Music,Podcasts,Ringtones,Alarms,Notifications,Pictures,Movies,Download. So my question is:
- How do I create a new directory of my own?
- How can I make it invisible to the user? so that user will not get frustrated with the extra folder.
You can use coder_For_Life22's answer about creating the folders, and then to make it "more-invisible" to the users, you can do the following:
- Name it starting with dot. e.g. ".yourappname"
- Put an empty file ".nomedia" into your folder. This prevents the media scanner from recording the files you have on that folder.
这篇关于安卓:使用getExternalStoragePublicDirectory(字符串型)在外部存储写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!