Why when I do :
FileWriter fw = new FileWriter("/data/data/com.myapp.client/files/myfile.json", true/*append*/);
on some very few device (one most of them it's work well) I receive : /data/data/com.myapp.client/files/myfile.json (No such file or directory)
. How can I avoid this error ?
Don't hardcode the path, use Context.getFilesDir
instead
File file = new File(context.getFilesDir(), "file.json")
See this for reference.