14

Do you need any permission to read data from an sdcard? I found the write permission but nothing for read.

Raj
  • 22,346
  • 14
  • 99
  • 142
Daniel Nysveen
  • 161
  • 1
  • 1
  • 4

6 Answers6

37

Do not forget to add

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

to your manifest file

savepopulation
  • 11,736
  • 4
  • 55
  • 80
  • Your answer needs more explanation. It's not very clear – eliasah Jul 02 '14 at 07:28
  • 2
    @Taylan: We expect answers here to explain themselves, not just dump code. You should explain what is causing the issue described, and why; then explain your fix and why it works. – Andrew Barber Jul 03 '14 at 13:36
  • 18
    Hey come'on, his answer is fairly self-explanatory. It state that you need to ask for more permissions in the manifest and it explains how to do that. What did you not understand about this ? –  Jul 30 '14 at 18:39
17

If you are using android version 4.1 (Jelly Bean), you have to insert the following permission into your application's manifest file:

READ_EXTERNAL_STORAGE

http://developer.android.com/reference/android/Manifest.permission.html#READ_EXTERNAL_STORAGE

gonzobrains
  • 7,856
  • 14
  • 81
  • 132
Vishwanath.M
  • 6,235
  • 11
  • 42
  • 56
  • 2
    Currently it is unenforced, so you don't actually need it. But it is a good idea to do it anyway. You can enable enforcement in the developer settings, as described in the docs. – Timmmm Nov 28 '12 at 15:15
  • 1
    if he includes the Write Permission, no need to include the Read permission – Lion789 Mar 13 '14 at 14:43
3

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

plackemacher
  • 4,216
  • 1
  • 23
  • 26
Roy Hinkley
  • 10,111
  • 21
  • 80
  • 120
  • 2
    According to the link you posted "In order to read or write files on the external storage, your app must acquire the READ_EXTERNAL_STORAGE or WRITE_EXTERNAL_STORAGE system permissions." – Mihai Bujanca Jan 19 '17 at 12:34
0

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.

sivag1
  • 4,734
  • 3
  • 32
  • 35
0

You need to add WRITE_EXTERNAL_STORAGE permission if you want to dir get list file.

phnghue
  • 1,578
  • 2
  • 10
  • 9
-2

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"