app is crashing in very specific case
if i install the app while the device local is English than no crash happen and everything is working as it should be.
if i change the device local to Arabic after the app being installed on English version than no crash too.
- if i uninstall the app than change the device to local Arabic than install the app for first time, than the app crash and the logcat doesnt show where or which line, and the app crash even if i dont call the local database in splashscreen.
Error log is :
android.database.sqlite.SQLiteException: no such column: ١٥٦٤٤١٠١٢٩٥٤٢ (code 1): , while compiling: DELETE FROM workspec WHERE state IN (2, 3, 5) AND (period_start_time + minimum_retention_duration) < ١٥٦٤٤١٠١٢٩٥٤٢ AND(SELECT COUNT(*)=0 FROM dependency WHERE prerequisite_id=id AND work_spec_id NOT IN (SELECT id FROM workspec WHERE state IN (2, 3, 5)))
#################################################################
Error Code : 1 (SQLITE_ERROR)
Caused By : SQL(query) error or missing database.
(no such column: ١٥٦٤٤١٠١٢٩٥٤٢ (code 1): , while compiling: DELETE FROM workspec WHERE state IN (2, 3, 5) AND (period_start_time + minimum_retention_duration) < ١٥٦٤٤١٠١٢٩٥٤٢ AND(SELECT COUNT(*)=0 FROM dependency WHERE prerequisite_id=id AND work_spec_id NOT IN (SELECT id FROM workspec WHERE state IN (2, 3, 5))))
#################################################################
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1221)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:695)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:59)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:2213)
at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:2142)
at android.arch.persistence.db.framework.FrameworkSQLiteDatabase.execSQL(FrameworkSQLiteDatabase.java:240)
at androidx.work.impl.WorkDatabase$1.onOpen(WorkDatabase.java:114)
at androidx.work.impl.WorkDatabase_Impl$1.onOpen(WorkDatabase_Impl.java:82)
at android.arch.persistence.room.RoomOpenHelper.onOpen(RoomOpenHelper.java:101)
at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.onOpen(FrameworkSQLiteOpenHelper.java:133)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:349)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:238)
at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getWritableSupportDatabase(FrameworkSQLiteOpenHelper.java:93)
at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper.getWritableDatabase(FrameworkSQLiteOpenHelper.java:54)
at android.arch.persistence.room.RoomDatabase.compileStatement(RoomDatabase.java:204)
at android.arch.persistence.room.SharedSQLiteStatement.createNewStatement(SharedSQLiteStatement.java:65)
at android.arch.persistence.room.SharedSQLiteStatement.getStmt(SharedSQLiteStatement.java:72)
at android.arch.persistence.room.SharedSQLiteStatement.acquire(SharedSQLiteStatement.java:87)
at androidx.work.impl.model.WorkSpecDao_Impl.resetScheduledState(WorkSpecDao_Impl.java:326)
at androidx.work.impl.WorkManagerImpl.rescheduleEligibleWork(WorkManagerImpl.java:393)
at androidx.work.impl.utils.ForceStopRunnable.run(ForceStopRunnable.java:66)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
I have multi-able database but they are all the same as the following code :
public static String getSqlCreation() {
return "CREATE TABLE IF NOT EXISTS " + TB_NAME + " (" + "id INTEGER PRIMARY KEY AUTOINCREMENT," +
Prodcut_id + " TEXT, " +
Prodcut_code + " TEXT, " +
Prodcut_name + " TEXT, " +
Prodcut_new_price + " TEXT, " +
Prodcut_old_price + " TEXT, " +
Prodcut_image + " TEXT, " +
Product_rating + " TEXT, " +
Product_quantity + " TEXT NOT NULL)";
}
public DBRecentViewHelper(Context context) {
super(context, DB_NAME, null, DB_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
try {
db.execSQL(DBRecentViewConstants.getSqlCreation());
} catch (SQLException e) {
e.printStackTrace();
}
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " + DBRecentViewConstants.TB_NAME);
onCreate(db);
}
UPDATE
private DB_Tags_Helper DBhelper;
private SQLiteDatabase db;
public DB_Tags_Adapter(Context ctx) {
this.context = ctx;
DBhelper = new DB_Tags_Helper(context);
}
public DB_Tags_Adapter openDB() {
try {
db = DBhelper.getWritableDatabase();
} catch (SQLException e) {
e.printStackTrace();
}
return this;
}
public DB_Tags_Adapter open() throws SQLiteException {
db = DBhelper.getWritableDatabase();
return this;
}
public boolean isCreated() {
if (db != null) {
return db.isOpen();
}
return false;
}
public boolean isOpen() {
return db.isOpen();
}
public void close() {
try {
DBhelper.close();
db.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
public Cursor getAllData() {
String[] columns = {DB_Tags_Constants.ROW_ID, DB_Tags_Constants.Tag_name_Ar, DB_Tags_Constants.Tag_name_EN,
DB_Tags_Constants.Tag_Code};
return db.query(DB_Tags_Constants.TB_NAME, columns, null, null, null, null, null);
}
public void clear() { /// to clear whole DB
db.execSQL("delete from " + DB_Tags_Constants.TB_NAME);
}
public void Delete(String tablename, String pos) {
try {
db.delete(tablename, "tag_code" + "='" + pos + "'", null);
} catch (SQLException e) {
e.printStackTrace();