Android : Saving Files to SD Card

23,234

Solution 1

Are you absolutely certain the file isn't being saved to the SD card? I thought I was having the same problem. It turned out that I was saving correctly to the SD card the whole time, but the gallery wasn't being refreshed to show the files I had just saved. Use Astro File Manager to make sure the file isn't already being saved to the card. If this is the problem, add this line to refresh the gallery:

sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"
                + Environment.getExternalStorageDirectory())));

Solution 2

This answer should help: Permission to write on SD card android . Don't forget that you need to declare in your Android.xml file <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Share:
23,234
Archaos
Author by

Archaos

Updated on August 09, 2020

Comments

  • Archaos
    Archaos over 3 years

    I am trying to save a file out from within my app to the external storage of a device. Specifically, I am trying to save a sound out.

    I've followed every 'tutorial' on doing this, and none of it seemed particularly confusing to me, yet it just will not work for me. No file is ever created on the SD card at all, much less actually transferring over the information.

    I've assumed I am somehow not getting the correct path to the card, but no matter what I have tried it doesn't work. I have tried entering just "/sdcard/", as well as using the getExternalStorageDirectory() method, among other random experiments.

    After spending over half the day on something that would seem so trivial I can't even think straight anymore, so I hope you will excuse some of the lack of detail I'm providing, but any suggestion would be helpful at this point.

  • Archaos
    Archaos about 13 years
    I definitely have the permissions set, so that isn't the case for me.