We have a sqlite database in our Application. Its working fine for all the users but few of them experiencing the Caused by: android.database.sqlite.SQLiteException: n
The problem is because some of device is upgrading your app, so the checkDataBase()
returning true
, so you are not calling copyDataBase()
. So you are using previous database which doesn't have generalSettings
table.
To solve this try:
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
if(newVersion>oldVersion)
copyDatabase();
}
and also update your constructor:
public InstallDB(Context context, String name) {
super(context, name, null, DB_VERSION);
// DB_VERSION is an int,update it every new build
this.ctx = context;
this.DBNAME = name;
this.DBPATH = this.ctx.getDatabasePath(DBNAME).getAbsolutePath();
Log.e("Path 1", DBPATH);
}