Writing a text file to SDCard gives a IllegalArgumentException in Android
openFileOuput() doesn't accept paths, only a file name.
Error writing to SD Card
openFileOutput()
is for opening files in your program data folder, which is located on the internal memory, you may only supply the file name, not the path, hence the complain mnt/scard/PatRecords/testfile.txt contains a file separator
.
if you want to open files on the SD card, you have to use FileOutputStream()
or something like that:
File of = new File(Environment.getExternalStorageDirectory(), filename);
FileOutputStream fos = new FileOutputStream(file);
fos.write(data);
fos.flush();
fos.close();
Saving file on SD card gets an error
I used this command to unmount
umount /media/sdcard
And it saved the problem.
Related Topics
Gradle Duplicate Entry: Java.Util.Zip.Zipexception
How to Make Zoomable Linearlayout
Room - Livedata Observer Does Not Trigger When Database Is Updated
How to Store Image Retrieved from Url in a SQLite Database
Could Not Launch Emulator in Android Studio
Decoding Raw H264 Stream in Android
Resize Image to Full Width and Variable Height with Picasso
Advantages of Using Bundle Instead of Direct Intent Putextra() in Android
How to Give Notifications on Android on Specific Time
@Android Display /Res/Viewable in Webview
Cannot Call Getsupportfragmentmanager() from Activity
How to Configure Launcher Activity Programmatically in Android
How to Create Custom Shape Button with Selector in Android
Calledfromwrongthreadexception
When Should One Use Rxjava Observable and When Simple Callback on Android
How to Hide One Item in an Android Spinner
How to Have a Listview/Recyclerview Inside a Parent Recyclerview