特定应用在外部存储设备上的文件夹的权限 [英] Permission of app specific folder on external storage

查看:179
本文介绍了特定应用在外部存储设备上的文件夹的权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以按以下说明解释应用程序特定文件夹/Android/data/< package_name>/files/的权限 http://developer.android.com/guide/topics/data/data-storage.html#filesExternal

尚不清楚它何时真正是该应用程序的私有应用程序以及何时可以被世界范围读取.启用USB大容量存储后,外部存储中的文件(包括应用程序特定的文件夹)是否可以在世界范围内读取?

我尝试使用文件管理器应用程序(ASTRO文件管理器),并且可以在sdcard上的应用程序特定文件夹中查看/打开文件,而与设置"下开发人员选项中的设置Protect USB storage无关.我正在使用运行Android 4.3版本的Google Nexus 4.

因此,当此文件夹/Android/data/appname/files/确实是该应用程序的专用文件夹时,会造成混淆.

谢谢.

解决方案

我们来谈谈Android安全性,对吧?

  1. 您无法在无根设备上访问应用程序的主目录.这本来是一个主要的安全漏洞.

  2. 不建议创建WORLD_READABLE文件,并根据API中的文字判断,这是弃用"表示弃用"的情况之一.

  3. 所以-您想在应用程序之间传递数据吗?

    a.您可以将文件保留在设置的位置,以供第二个应用获取.不过,这是一个坏主意.它会乱扔用户的存储空间,完全没有安全性,第二个应用程序不会收到有关即将进行的更新的通知,并且您无法轻松确定事务状态.我建议您远离这种方法.即使如此,我还是在下面的UPDATE部分中进行了详细说明.

    b.对于简单的小块数据,建议您使用 Intent/BroadcastReceiver方法.

    c.您可以使用 ContentProvider方法您想以正确的方式做事吗?

    d.您可以使用意图/服务方法

    e.对于真正的IPC-使用AIDL .

更新:

我建议您先阅读 Google的文章直通.本文显然涉及在应用程序之间传输大文件的情况.另外,正如您可以清楚地看到的那样,该术语非常令人困惑.

因此,让我们根据Google关于该主题的文章来回顾您的问题.

内部存储空间是您的应用程序专用的,其他应用程序无法访问.您可以通过 Context.html#getFilesDir访问其目录结构().

请注意:

  1. 当用户卸载应用程序时,此处写入的文件将被删除.

外部存储可以在物理上(内置存储)或外部(可移动SD卡).这里没有安全模型,文件是可见的,并且全世界都可以访问.您可以通过访问外部目录结构Context.html#getExternalFilesDir().请注意:

  1. 此目录可能无法访问(当用户将设备连接到计算机时或当他移除SD卡时).

  2. 每个设备用户可能有一个单独的目录.

  3. 即使用户卸载了该应用程序,文件仍然保留.

Can someone explain the permission of the app specific folder /Android/data/< package_name>/files/ as described here http://developer.android.com/guide/topics/data/data-storage.html#filesExternal

It is not clear when it is truly private to the app and when it is world-readable. Is it the case that when the USB mass storage is enabled the files in the external storage, including the app specific folder, are world readable?

I tried using a file manager app (ASTRO file manager) and I am able to see/open files in the app specific folders on the sdcard and this is irrespective of the setting Protect USB storage in the developer options under Settings. I am using Google Nexus 4 running 4.3 version of android.

So it's confusing when this folder /Android/data/appname/files/ is really private to the app.

thanks.

解决方案

Let's talk some Android security, shall we?

  1. You can not access an application's home directory, on an unrooted device. This would have been a MAJOR security hole.

  2. Creating WORLD_READABLE files is deprecated, and judging by the text in the API, this is one of those cases where "decperacted" means "deprecated".

  3. So - you wanna pass data between applications?

    a. You can leave a file in a set place for the 2nd app to fetch. This is a bad idea though. It litters the user's storage space, there is NO SECURITY at all, the 2nd app is not notified about pending updates and you can not easily determine the state of affairs. I suggest you stear away from this approach. Even though, I've included some elaboration in the UPDATE section below.

    b. For simple, small chunks of data, I suggest you go the Intent/BroadcastReceiver approach.

    c. You can go the ContentProvider approach is you wanna do things the right way.

    d. You can go the Intent/Service approach.

    e. For true IPC - use AIDL.

UPDATE:

I suggest you begin by reading Google's article throughly. This article clearly deals with the case of transfering large files between apps. Also, as you can clearly witness, the terminology is quite confusing.

So let's review your question in light of Google's article on the subject.

Internal storage is private to your application and can not be accessed by other apps. You can access its directory structure via Context.html#getFilesDir().

Please mind that:

  1. Files written here are deleted when the user uninstalls the app.

External storage can be physically internal (built in storage) or external (removable SD card). There is no security model here, files are visible and accessible to the world. You can access the external directory structure via Context.html#getExternalFilesDir(). Please mind that:

  1. This direcory might become unaccessible (when the user connects the device to a computer or when he removes the SD card).

  2. There might be a seperate directory per device user.

  3. Files remain even when the user uninstalls the app.

这篇关于特定应用在外部存储设备上的文件夹的权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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