I’m new in android development and for now I would like to create an app that uses a SQLite DB. I’m having trouble to understand one thing about the PATH of the DB. I saw this on a guide to succeed in what I want, take a look:
public class DataBaseHelper extends SQLiteOpenHelper{
//The Android's default system path of your application database.
private static String DB_PATH = "/data/data/YOUR_PACKAGE/databases/";
private static String DB_NAME = "myDBName";
...
}
When it says path there, it’s the path of the SQLite db file on my desktop? That’s is gonna be used while I’m running at the AVD? And.. when I change the db to my tablet (“localhost” of the db this way) I need to specify the path inside my tablet?am I correct?
No, that path is the path to the location where your db will be located on the device. The DB is normally kept in a path containing your package name (which is secure and no other app can access unless the phone is rooted).
If your package name were “com.test.victor”, the path to the DB on the device would be:
If you are not creating the DB from scratch via your app and would rather use a pre-created DB, you need to put that DB in your assets folder, and then copy the db to the proper directory to be used by Android when you start the app.
Here’s a link to another question I recently answered addressing copying a database file from assets for use.