安卓:使用getExternalStoragePublicDirectory(字符串型)在外部存储写 [英] Android: write on external storage using getExternalStoragePublicDirectory(String type)

查看:700
本文介绍了安卓:使用getExternalStoragePublicDirectory(字符串型)在外部存储写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我想保存在Android上的外部存储一些数据。我已经看了看哪里是说 getExternalStoragePublicDirectory(字符串型)的API
如果有必要这个方法将创建相应的目录。
这些都是缺省目录:音乐,播客,铃声,报警,通知,图片,电影,下载。所以我的问题是:


  1. 如何创建我自己的?
  2. 的新目录
  3. 我怎样才能使它对用户不可见?这样用户就不会感到失望,其中额外的文件夹中。


解决方案

您可以用coder_For_Life22的回答关于创建的文件夹,然后使其更看不见的用户,你可以做到以下几点:


  1. 将它命名为开始点。例如.yourappname

  2. 把一个空文件.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:

  1. How do I create a new directory of my own?
  2. 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:

  1. Name it starting with dot. e.g. ".yourappname"
  2. Put an empty file ".nomedia" into your folder. This prevents the media scanner from recording the files you have on that folder.

这篇关于安卓:使用getExternalStoragePublicDirectory(字符串型)在外部存储写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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