I have already coded the below function call and is using it in one app. That is working in the same phone. Now, I copy the function to another app but it causes catch error at the line:
bR = new BufferedReader(new FileReader(gpxfile));
Anyone know why is this? And how can I inspect the error message? Noted I already added the permissions:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
public void addPhoneEntriesFromFile(String thisfile) {
String aDataRow;
// load from textfile
try {
String newpath;
String subfolder = "DriveSyncFiles/_sync";
newpath = Environment.getExternalStorageDirectory().getPath();
if (!subfolder.equals("")) {
newpath += "/" + subfolder;
}
newpath += "/";
BufferedReader bR;
if (thisfile.equals("")){
thisfile = "myaddress.txt";
}
File gpxfile = new File(newpath, thisfile );
myFun.ShowToast(getApplicationContext(), "begin");
bR = new BufferedReader(new FileReader(gpxfile));
aDataRow = "";
Boolean stopWhile = false;
while (((aDataRow = bR.readLine()) != null) && (stopWhile == false)) {
if (aDataRow.equals("===")) {
stopWhile = true;
} else {
Log.d("mycode", aDataRow);
}
}
bR.close();
myFun.ShowToast(getApplicationContext(), "end");
} catch (IOException e) {
e.printStackTrace();
}
}