I\'m trying to make a simple check if the file exist. I saw similar questions here, but they didn\'t help. When I run my application, the app crashes and I got message \"Unf
I think that problem is here:
getBaseContext()
where it is assigned to NULL
. You really don't need this line. You can simply achieve your goal with
String path = Environment.getExternalStorageDirectory().getPath() + "/ping.xml";
File f = new File(path);
if (f.exists()) {
// do your stuff
}
else {
// do your stuff
}
If you or someone else have Samsung Galaxy S3, please follow @Raghunandan's answer because in this case getExternalStorageDirectory()
returns internal memory.