I have an app working with a single local sqllite database in data/data/com.endel.psicotest/databases/psico.db
but I'm trying to connect to a secundary and old db in /data/data/com.example.psicotestv1/databases/
but when I had tried SQLiteDatabase db = getReadableDatabase(); in my DataBaseHelper_OLD return me the first database :(
public DBMain_OLD(Context contexto) {
super(contexto, DB_NAME, null, DB_VERSION);
//Calculamos la ruta de la base de datos
File file = new File(contexto.getDatabasePath(DB_NAME).getPath());
DB_PATH_OLD = "data/data/com.example.psicotest3/databases/";
this.context = contexto;
}
my secundary constructor with the DB_PATH_OLD
DataBaseHelper_OLD myDbHelper_OLD = new DataBaseHelper_OLD(contexto);
Item item_OLD = myDbHelper_OLD.GetItemId(idPregunta);
I got the value of first database :(
If you want to share a DB between 2 apps, you will need to implement a ContentProvider . You can't share a simple database because an application normally can't access other applications' folders. (I said normally because apps with roots access can). And this is why when you call SQLiteDatabase db = getReadableDatabase();
you only get the DB from your app.
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.