Super beginner here.
I've created a SQLite database and I want to view it with the SQLiteManager plugin, but my database doesn't add the .db extension on my (virtual) device. So far I've had to copy the file to my computer, change the extension, and push it back in order for the SQLiteManager icon to enable. Then I can see the database.
How can I avoid this run-around?
Also, someone mentioned I shouldn't rely on "/data/data/" to be the correct path. They suggested I use Context.openOrCreateDatabase
or one of the get*Path
or get*Dir
methods. Could someone elaborate on these? The code I used is from a Youtube tutorial I saw.
Here's the code that defines the path:
try {
String destPath = "/data/data/" + getPackageName() + "/databases/GradesDB.db";
File f = new File(destPath);
if(!f.exists()) {
CopyDB( getBaseContext().getAssets().open("mydb"),
new FileOutputStream(destPath));
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}