This is supposed to be pretty easy but I'm not being able to find a SQLite file in my Genimotion emulator or in my mobile phone either.
The code is pretty simple:
private boolean ddbbFileExistsInMobile() {
File f_ddbb_local = new File(DDBB_PATH, DataBaseHelper.DDBB_file);
return f_ddbb_local.exists();
}
if(android.os.Build.VERSION.SDK_INT >= 17){ // 17-> 4.2 Android
DDBB_PATH = context.getApplicationInfo().dataDir + "/databases/";
}
else
{
DDBB_PATH = "/data/data/" + context.getPackageName() + "/databases/";
}
if(ddbbFileExistsInMobile()) {
File f_ddbb_local = new File(DDBB_PATH, DataBaseHelper.DDBB_file);
f_ddbb_local.delete();
}
This last if allways returns false.
I also checked with this code afterwards, that the PATH is correct.
File dbFile = mContext.getDatabasePath(DataBaseHelper.DDBB_file);
String aux = dbFile.getAbsolutePath();
Log.d(LOG_TAG, aux);
I have really no clues what is happening. Why that file can't be found?
The most extrange thing is that I can delete it with this code:
f_ddbb_local = new File(DDBB_PATH, DataBaseHelper.DDBB_file);
f_ddbb_local.delete();
So if I delete it directly, it erased, but if I use the previous function: ddbbFileExistsInMobile() the program never goes into the if.
Aucun commentaire:
Enregistrer un commentaire