将公共文件保存在内部存储器中 [英] Saving public files in the internal storage

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

问题描述

我有一个应用程序,可以保存从服务器下载的文件.这些文件不是我的应用程序专用的,其他应用程序也应该可以访问.我想知道SD卡不在时保存这些文件的正确路径是什么.对于SD卡,有众所周知的API-

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()

在某些设备上,内部存储器由/emmc/表示.

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

如果有人可以详细介绍/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?

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

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

推荐答案

在某些设备上,内部存储器由/emmc/表示.

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

/emmc/可能存在于某些设备上,并且可能是内部设备,但可能无法被应用程序访问,除非它恰好是getExternalStorageDirectory()返回的内容,否则它肯定不是Android SDK的一部分.

/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?

否.

还是第三个记忆?

Or is it the third memory?

询问设备制造商.

我应该使用带有MODE_WORLD_READABLE的openFileOutput()保存文件吗?

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

这不可能抽象地回答.您说您的文件也应可供其他应用程序访问",但您尚未说明为什么希望其他任何应用程序都关心您的文件.其他应用程序将不会在目录中扫描文件-充其量,它们将允许用户浏览外部存储.拥有文件MODE_WORLD_READABLE的唯一原因是您的应用程序是否会触发另一个应用程序对该文件执行某些操作(例如ACTION_VIEW Intent).

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天全站免登陆