Archaos
Archaos

Reputation: 31

Android : Saving Files to SD Card

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.

Upvotes: 3

Views: 23313

Answers (2)

Mike Ortiz
Mike Ortiz

Reputation: 4041

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())));

Upvotes: 6

I82Much
I82Much

Reputation: 27326

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" />

Upvotes: 3

Related Questions