The problem is that I put the file through the DDMS Perspective in data and /data/data folder and when I try to access to that files, the FileNotFoundException occures.
Code:
String path = Environment.getExternalStorageState()+"/analyzer_settings.xml";
System.out.println(path);
try {
Scanner in = new Scanner(new File(path));
while (in.hasNext()) {
System.out.println(in.nextLine());
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Exception with print:
07-11 17:10:02.470: I/System.out(13506): mounted/analyzer_settings.xml
07-11 17:10:02.500: W/System.err(13506): java.io.FileNotFoundException: /mounted/analyzer_settings.xml: open failed: ENOENT (No such file or directory)
I’ve tried also:
String path = Environment.getExternalStorageState()+"/data/analyzer_settings.xml";
or
String path = Environment.getExternalStorageState()+"/data/data/analyzer_settings.xml";
nothing worked for me.
use
instead of
EDIT:
Because as doc says:
getExternalStorageDirectory ():
and
getExternalStorageState():