I am trying to create a folder and several subdirectory within it on the SD Card... I then want to transfer files that I have stored in /res/raw to that folder... I addition, I want this to only happen once, the first time the program is ever run. I realize that this is ridiculously open-ended, and that I am asking a lot... but any help would be greatly appreciated.
views:
91answers:
1
+1
A:
Use Environment.getExternalStorageDirectory()
to get a File
object pointing to the root of external storage for the device (which may or may not be an "SD Card"). Use Java file I/O to see if your directory exists. If it does not, create your subdirectories, again using Java file I/O. Copy your data from the raw resource via...you guessed it...Java file I/O and getResources().openRawResource()
.
CommonsWare
2010-10-03 22:43:34
Thank You very much for all the info!!! I will give it a try!
Frank Bozzo
2010-10-03 22:56:51
Additionally make sure your application has the SD Card read/write permission (http://stackoverflow.com/questions/2121833/permission-to-write-to-the-sd-card)
Dave G
2010-10-04 12:32:33
Even though not specifically metioned by Frank, I think he may move the file there. Actually it doesn't make much sense to move files from the resources to the SD card as you can't remove the resources from the original APK. So unless it's another wallpaper or additional-levels/content app, it may be more usefull not to store the said resources at all in your APK but instead download it on demand
Tseng
2010-10-04 15:47:27
@Tseng: The downside of download-on-demand is it assumes an Internet connection.
CommonsWare
2010-10-04 16:18:45