I want to ask about how to read a DB from another app. We already have an app running on the device, but we have another project that refers to the previous DB.
I have dbAdapter.class to read the path to the DB, but I found some errors like "unable to open the database.
private static String DB_PATH = "/data/data/com.project.factory.apps/databases/"; private static final String DB_NAME = "dbData.db"; private static String DB_PATH_SDCARD = Environment.getExternalStorageDirectory() + "/data/com.project.factory.apps/databases/"; private Context myContext; public dbAdapter(Context context) { super(context, DB_NAME, null, 1); myContext = context; } public boolean createDatabase(){ if(DatabaseIsExist()) { return false; } else{ return false; } } private boolean DatabaseIsExist(){ checkDb = null; try{ String myPath = DB_PATH + DB_NAME; File directory = new File(DB_PATH_SDCARD); if(!directory.exists()) directory.mkdirs(); checkDb = SQLiteDatabase.openDatabase("/data/data/com.project.factory.apps/databases/dbData.db", null, SQLiteDatabase.NO_LOCALIZED_COLLATORS); } catch(SQLiteException e){ Log.e("File not found in data",e.toString()); return false; } return true; } public List<t_listInfo> getList() { try { dataAdapter = DaoManager.createDao(this.getConnectionSource(), t_listInfo.class); return dataAdapter.queryForAll(); } catch (Exception e) { e.printStackTrace(); return null; } } on MyActivity.Class
db.createDatabase(); db.getReadableDatabase(); data = db.getList(); I got an error in call the getList() function and need a suggestion or correction if the code was wrong.