java.io.FileNotFoundException with FileWriter
The following line
FileWriter fw = new FileWriter("/log0.txt");
throws:
java.io.FileNotFoundException: /log0.txt (Read-only file system)
I'm testing this on device an开发者_JAVA技巧d "USB storage" is off. Any idea why this happens?
You are trying to create a file in the root path "/". Try to create the file in a writable path like "/data/" or "/mnt/sdcard" or use the methods: Environment.getExternalStorageDirectory()
See also:
http://developer.android.com/guide/topics/data/data-storage.html
Make sure log0.txt is present in ur device. Other wise it give exception
Here is a tutorial, which begins describing your issue. It will be helpful to read.
精彩评论