Questions tagged [android-sdcard]

SD Card is a Secure Digital Card available with Android which acts as the External Storage Directory.

Android supports also access to an external storage system e.g. the SD card. All files and directories on the external storage system are readable for all applications.

You can get the path to the external storage system via the Environment.getExternalStorageDirectory() method. To write to the external storage system your application needs the android.permission.WRITE_EXTERNAL_STORAGE permission.
Note: Beginning with Android 4.4, that permission is not required if you're reading or writing only files that are private to your app. For more information, see the section below about saving files that are app-private.

Before you do any work with the external storage, you should always call getExternalStorageState() to check whether the media is available. The media might be mounted to a computer, missing, read-only, or in some other state.

To check for the write permisson you should check the result of the

Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)

And for the read permisson

Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED) ||
Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED_READ_ONLY)

Useful links

1499 questions
46
votes
5 answers

is there a maximum size to android internal storage allocated for an app?

I want to save a json file with all the application data (something similar to preference) but im not sure what is the limit size, because if the app cant use this file it will not function probably. is this information known beforehand and the OS…
Jimmy
  • 10,427
  • 18
  • 67
  • 122
44
votes
16 answers

How to access /storage/emulated/0/

I have written a code to record audio and save it to below file location. private String getFilename() { String filepath = Environment.getExternalStorageDirectory().getPath(); File file = new File(filepath, AUDIO_RECORDER_FOLDER); if…
nerdy_me
  • 451
  • 1
  • 5
  • 7
40
votes
7 answers

Simple mediaplayer play mp3 from file path?

I have a very simple mediaplayer that play background. It calls file from the apk, but I want it to play from any directory like as music or sdcard. Here is my code: private MediaPlayer mpintro; . . mpintro = MediaPlayer.create(this,…
John simit
  • 1,305
  • 2
  • 11
  • 14
39
votes
2 answers

Do I have to declare both WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE?

Is it enough to declare or do I also have to declare ? The Javadocs omit this important…
Jeff Axelrod
  • 27,676
  • 31
  • 147
  • 246
37
votes
8 answers

Android Open External Storage directory(sdcard) for storing file

I want to open external storage directory path for saving file programatically.I tried but not getting sdcard path. How can i do this?is there any solution for this?? private File path = new…
yuva ツ
  • 3,707
  • 9
  • 50
  • 78
36
votes
9 answers

Saving Logcat to a text file in Android Device

I had found some crashes while running the application in android device, which is not showing in emulator. So i need to save the Logcat in a text file in my device's memory or SD card. Could you please suggest me good method to do this?
Nithin Michael
  • 2,166
  • 11
  • 32
  • 56
32
votes
4 answers

Removable storage (external) sdcard path by manufacturers

I've been Googling around but it is sooooo hard to find what manufacturers/models use which path for sdcard/external storage. I am NOT talking about the internal storage path which can be found by: Environment.getExternalStorageDirectory() I know…
jclova
  • 5,466
  • 16
  • 52
  • 78
31
votes
6 answers

storing android application data on SD Card

Is there a way to store android application data on the SD card instead of in the internal memory? I know how to transfer the application sqlite database from the internal memory to the SDCard, but what if the internal memory gets full in the first…
user121196
  • 30,032
  • 57
  • 148
  • 198
26
votes
2 answers

How to get access to all SD-cards, using the new Lollipop API?

background Starting with Lollipop, apps can get access to real SD-cards (after it was not accessible on Kitkat, and was not officially supported yet worked on previous versions), as I've asked about here. The problem Because it has become quite rare…
android developer
  • 114,585
  • 152
  • 739
  • 1,270
25
votes
1 answer

Android SD Card Write Permission using SAF (Storage Access Framework)

After a lot of findings about how to write(and rename) a file in SD Card (android 5 and above), I think the new SAF provided by android will be required to take permission from user to write SD card file. I have seen in this File Manger Application…
24
votes
3 answers

Copying raw file into SDCard?

I've some audio files in my res/raw folder. For some reasons, i want to copy this files to my SDCard When, my application starts. How can i done this? Anyone guide me?
Praveenkumar
  • 24,084
  • 23
  • 95
  • 173
24
votes
2 answers

How do I transfer an image from its URL to the SD card?

How can I save an images to the SD card that I retrieve from the image's URL?
Jameskittu
  • 598
  • 2
  • 8
  • 17
23
votes
2 answers

reading a specific file from sdcard in android

how to read a specific file from sdcard. i have pushed the file in sdcard through DDMS and i am trying to read it though this way but this give me exception. can anybody tell me how to point exactly on that file? my code is this. String path =…
sajjoo
  • 6,576
  • 20
  • 65
  • 86
22
votes
3 answers

How to create a video thumbnail from a video file path in Android?

I want to create a thumbnail of a video from the SD card path. How can I do that?
Parth Bhayani
  • 1,894
  • 3
  • 17
  • 35
22
votes
5 answers

Android - Save images in an specific folder

I need to save the pictures taken with my app in an specific folder. I've read many solutions to this problem but I couldn't make any of them work so I ask for help. MainActivity.java public void onClick(View v) { Intent camera = new Intent( …