I am trying to write a file to the external storage of the android.
On the AndroidManifest.xml I’ve added (within the manifest tag)
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
then I tried:
File root = Environment.getExternalStorageDirectory();
File file = new File(root, xmlFilename);
file.createNewFile();
And then I get the exception.
How may I resolve this?
Make sure your SD card is not mounted to your computer. If you have enabled USB storage, your SD card becomes read-only for Android.
Other then that, your application looks fine and should work.
Oh, and I would modify your code in a next way: