简体   繁体   English

如何访问外部和内部存储?

[英]How To Access External and internal storage?

I actually want to access the files on android system. 我实际上想访问android系统上的文件。 I manage to read the files and directories in the external storage of android. 我设法读取android的外部存储器中的文件和目录。 My questions are : 我的问题是:

  1. How can I access the directories and files of the internal storage(Specially videos, pics all of the applications which runs in android). 如何访问内部存储的目录和文件(特别是视频,所有在android中运行的应用程序的图片)。
  2. Where are stored the data of each application which installed in internal storage? 哪里存储了安装在内部存储中的每个应用程序的数据?
  3. Is it possible to transfer data which exists in the internal storage (from internal memory to external storage? 是否可以传输内部存储器中存在的数据(从内部存储器到外部存储器?
  4. I read that external storage is world-readable? 我读到外部存储是世界可读的? what does that mean?(if a create an application then this application can access all the files that installed in external storage?) 这是什么意思?(如果创建一个应用程序,那么这个应用程序可以访问安装在外部存储中的所有文件?)

By default, an app cannot access data stored by another app. 默认情况下,应用无法访问其他应用存储的数据。 Permissions are applied to internal storage that make data written by an application not accessible outside of that application (your app cannot read anything written by another app). 权限应用于内部存储,使应用程序写入的数据无法在该应用程序外部访问(您的应用程序无法读取其他应用程序编写的任何内容)。 This can be changed, where an application can specify different permissions for ITS OWN data; 这可以更改,其中应用程序可以为ITS OWN数据指定不同的权限; basically, an app can allow others to read its data. 基本上,应用程序可以允许其他人读取其数据。 However, if an app does not specifically set its permissions to allow this, other apps cannot access its data. 但是,如果某个应用未明确设置其权限以允许此操作,则其他应用无法访问其数据。 This is a fundamental principle of the Android security/isolation model and is done at the Linux/kernel level, as each app runs under its own Linux UID and permissions are set within the filesystem only allowing that UID access to the app's directory structure (group and world permissions are set to 0 by default). 这是Android安全/隔离模型的基本原则,在Linux /内核级别完成,因为每个应用程序在其自己的Linux UID下运行,并且在文件系统中设置权限,仅允许UID访问应用程序的目录结构(组)和世界权限默认设置为0)。

This all goes out the window if you have access to root on the device (rooted phone and your app runs with root permissions), but we should consider that out-of-scope for your question. 如果你有权访问设备上的root(root用户手机和你的应用程序以root权限运行),这一切都会消失,但我们应该考虑你的问题超出范围。

External (SD card) storage is different in that it is considered free-for-all and permissions are not applied there (this is originally due to the filesystem typically used in SD not supporting permissions). 外部(SD卡)存储的不同之处在于它被认为是免费的,并且不会在那里应用权限(这最初是由于SD中通常使用的文件系统不支持权限)。 Any app can usually read anything written to the SD card by any other app, unless the original app does something to protect it (encrypt, etc). 任何应用程序通常都可以读取任何其他应用程序写入SD卡的任何内容,除非原始应用程序执行某些操作来保护它(加密等)。

This is all explained in great detail in Application Security for the Android Platform , just published by O'Reilly. 这一点在O'Reilly刚刚发布的Android平台应用程序安全性中进行了详细解释。

您必须编写FileProvider以使用其他应用程序访问特定于应用程序的文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM