允许从 SD 卡读取数据
从 SD 卡读取数据需要任何权限吗?我找到了写权限,但没有读权限。
Do you need any permission to read data from an sdcard? I found the write permission but nothing for read.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
不要忘记添加
到您的清单文件中
Do not forget to add
to your manifest file
如果您使用的是 android 版本 4.1 (Jelly Bean),则必须将以下权限插入应用程序的清单文件中:
http://developer.android.com/reference/android/Manifest.permission.html#READ_EXTERNAL_STORAGE
If you are using android version 4.1 (Jelly Bean), you have to insert the following permission into your application's manifest file:
http://developer.android.com/reference/android/Manifest.permission.html#READ_EXTERNAL_STORAGE
读取 SD 卡上的数据不需要特殊权限。因此,您存储在 SD 卡上的任何内容都可供任何应用程序读取。
有关更多信息,有关此问题的 Android 文档位于:http:// developer.android.com/guide/topics/data/data-storage.html
No special permissions are required to read data on the SD card. By virtue, anything you store on the SD card is visible for any app to read.
For more information, the Android documentation on the matter is here: http://developer.android.com/guide/topics/data/data-storage.html
这里的关键是你想读什么。如上所述,如果您正在阅读不是由您的应用程序创建的内容,则需要该权限。某些设备也可以让您摆脱这种情况,前提是设备上的开发人员选项允许这样做。但最好将其包含在清单中。
如果您只是阅读使用同一应用程序编写的内容,则不需要明确的许可。
Key here is what you want to read. As mentioned above, you need the permission if you are reading content NOT created by your app. Some devices lets you get away with this also, provided the developer options allow it on the device. But better to include it in the manifest.
If you are only reading what you wrote using the same app, no explicit permission is required.
如果你想dir获取列表文件,你需要添加WRITE_EXTERNAL_STORAGE权限。
You need to add WRITE_EXTERNAL_STORAGE permission if you want to dir get list file.
在 Linux 系统上,cd 到 SD 卡时,您可能需要复制和粘贴很长的路径名。根据您喜欢的编辑器尝试“sudo nano”或 sudo vi。这使我能够读取无法使用基于 GUI 的标准文本编辑器在 SD 卡上打开的文件。
例如,在 GUI 中,我尝试打开 SD 卡上 /etc 中的 passwd 文件。图标上有一个小x。 Leafpad 我的 Linux 编辑器无法打开文件“/media/UserDrake/28d3774e-c2bd-486f-bde0-3cbb17d2317c/etc/passwd-”权限被拒绝。
但是,如果我使用终端 cd / 然后使用剪切和粘贴 cd 到刚才提到的路径,因为输入确实很长。我可以用 sudo nano“路径上方”看到它
On a linux system cd to the sd card you may have a long path name to copy and paste. Try "sudo nano" or sudo vi depending on the editor you like. This enabled me to read files I could not open on the SD card with my standard gui based text editor.
For example in the GUI I tried to open passwd- file in /etc on my SD card. The icon has a little x on it. Leafpad my linux editor Failed to open the file '/media/UserDrake/28d3774e-c2bd-486f-bde0-3cbb17d2317c/etc/passwd-' permission denied.
However if I use terminal cd / then cd to the just mentioned path using cut and paste because it really is long to type. I CAN see it with sudo nano "above path"