安卓:保存在内部存储公用文件 [英] Android: Saving public files in the internal storage

查看:172
本文介绍了安卓:保存在内部存储公用文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个节省从服务器下载文件的应用程序。这些文件是不是私人的,以我的应用程序,并且可以访问其他应用程序。我想知道什么是正确的路径保存这些文件时,SD卡不存在。为SD卡,有公知的API -

  getExternalStorageDirectory()
 

有关在内部存储器中的应用程序的专用数据有 -

  Context.getFilesDir()
 

在某些设备上,内存是/ EMMC /.

这将是很有益的,如果有人能详细阐述/ EMMC /。我知道它代表的嵌入式存储卡,而不是present中的所有设备。这是不是真的再内部存储器的presentative?或者是它的第三个内存?

我应该用保存的文件 openFileOutput() MODE_WORLD_READABLE

感谢了很多,

阿克沙伊

解决方案
  

在某些设备上,内存是/ EMMC /.

/ EMMC / 可能存在某些设备上,它可能是内部的,但它可能无法访问应用程序,而且可以肯定的是不是Android SDK的一部分除非出现这种情况是什么 getExternalStorageDirectory()的回报。

  

这是不是真的再内部存储器的presentative?

没有。

  

或者是第三个内存?

请向您的设备制造商。

  

我应该保存使用openFileOutput()与MODE_WORLD_READABLE文件?

这是不可能的,在抽象的回答。你说你的文件应该是提供给其他应用程序,以及,但为什么你期望任何其他应用程序,以照顾一位你的文件,你有没有表示。其他应用程序将不会被扫描您的目录中的文件 - 充其量,他们将允许用户浏览外部存储。唯一的原因,有一个文件,是 MODE_WORLD_READABLE 是如果的应用程序的将被触发另一个应用程序做一些与文件(例如, ACTION_VIEW 意图)。

I have an application that saves files downloaded from a server. These files are not private to my application and should be accessible to other applications as well. I want to know what would be the correct path to save these files when the SD card is ABSENT. For the SD card, there is the well known API -

getExternalStorageDirectory()

For the application's private data in the internal memory there is -

Context.getFilesDir()

On some devices, the internal memory is represented by /emmc/.

It will be really helpful if someone could elaborate on /emmc/. I know it stands for embedded Memory card and is not present in all the devices. But is it really representative of the internal memory? Or is it the third memory?

Should I save the files using openFileOutput() with MODE_WORLD_READABLE ?

Thanks a lot,

Akshay

解决方案

On some devices, the internal memory is represented by /emmc/.

/emmc/ may exist on some devices, and it may be internal, but it may not be accessible to applications, and it certainly is not part of the Android SDK unless that happens to be what getExternalStorageDirectory() returns.

But is it really representative of the internal memory?

No.

Or is it the third memory?

Ask your device manufacturer.

Should I save the files using openFileOutput() with MODE_WORLD_READABLE ?

That is impossible to answer in the abstract. You say that your files "should be accessible to other applications as well", but you have not indicated why you expect any other application to care one bit about your files. Other applications will not be scanning your directories for files -- at best, they will allow users to browse external storage. The only reason to have a file that is MODE_WORLD_READABLE is if your application will be triggering another application to do something with the file (e.g., ACTION_VIEW Intent).

这篇关于安卓:保存在内部存储公用文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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