Default SD Card Storage with Alternate Device Internal Public Storage. I'm developing an app using API Level 8 and testing the app on a Samsung Intercept smartphone running Android 2.2.2 which has SD card storage. I don“t know if device Internal Public Storage is available on the Samsung Intercept.
This code is for saving user created files that should be shared and not deleted when the app is uninstalled. I'm trying to write code that will make the SD card storage the default for the app. In the case where the SD card is not available, the app will make a directory on the device Internal Public Storage. The app will return to using the directory on the SD card when the SD card is available. Testing the code below: when the SD card storage is available, the app will successfully make a directory on the SD card and read/write files. When I unmount the SD card and run the app, it fails to make a directory on the device Internal Public Storage, or anywhere else. For reference: Saving files that should be shared If you want to save files that are not specific to your application and that should not be deleted when your application is uninstalled, save them to one of the public directories on the external storage In API Level 8 or greater, use getExternalStoragePublicDirectory(), passing it the type of public directory you want... http://developer.android.com/guide/topics/data/data-storage.html The code: File subdirectory = Environment.getExternalStoragePublicDirectory("MyDirectory"); subdirectory.mkdirs(); File pathAndFileName = new File(subdirectory, FileName); FileWriter writer = new FileWriter(pathAndFileName); BufferedWriter out = new BufferedWriter(writer); out.write("\n" + ReportUpdate + "\n"); out.close(); I also tried replacing the first and second lines of the code above with the first and second lines of code below. I get exactly the same results as above. File directory = Environment.getExternalStorageDirectory(); File subdirectory = new File(directory, "MyDirectory"); subdirectory.mkdirs(); File pathAndFileName = new File(subdirectory, FileName); FileWriter writer = new FileWriter(pathAndFileName); BufferedWriter out = new BufferedWriter(writer); out.write("\n" + ReportUpdate + "\n"); out.close(); Thanks for your help. JediDroid -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

