I have an existing database which I want to use in an android application.
I understand that I should place the database in the assets folder and then create a databasehelper.
However, about every single tutorial mentions that I need the path to my database in this Helperclass.
How do I find that?
Especially if I am using only a virtual device?
The rest SEEMS quite selfexplaining but this?
its in /data/data/packageName/databases
use file explorer from DDMS.
OR
You can use:
String DB_PATH = "";
if(android.os.Build.VERSION.SDK_INT >= 17){
DB_PATH = context.getApplicationInfo().dataDir + "/databases/";
}
else
{
DB_PATH = "/data/data/" + context.getPackageName() + "/databases/";
}
For Jellybean 4.2 multi users:
DB_PATH = "/data/data/" + context.getPackageName() + "/databases/";
to:
DB_PATH = context.getApplicationInfo().dataDir + "/databases/";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.