This is how I create the file:
File directory = null;
File file = null;
try {
directory = new File(this.getExternalFilesDir(null));
} catch (Exception ex) {
ex.printStackTrace();
if (!directory.exists()) {
directory.mkdirs();
}
}
file = new File(directory, "user_data.json");
if (!file.exists()) {
try {
file.getParentFile().mkdirs();
file.createNewFile();
} catch (Exception e) {
e.printStackTrace();
}
}
and then this file appears in:
Android/data/com.mypackage.asd/files/user_data.json
but later on when I need it, using this code:
FileInputStream fis = null;
try {
fis = context.openFileInput("user_data.json");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
I get a NullPointerException and I see that the system looks for the file in
data/data/com.mypackage.asd/files/user_data.json
Why does it replace "Android" with "data" in the path?