Caused by: android.database.sqlite.SQLiteException: no such table: (code 1) Android

后端 未结 16 2397
一整个雨季
一整个雨季 2020-12-15 05:01

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

16条回答
  •  没有蜡笔的小新
    2020-12-15 05:39

    Suppose if you run your app with Database Version 1, then if you alter the table structure or add a new table, you must increase your Database Version to 2 and further if you make more changes to it.

    public class AppDatabase extends SQLiteOpenHelper {
    
        // Database Name
        private static final String DATABASE_NAME = "myDatabase";
    
        // Database Version
        private static final int DATABASE_VERSION = 1;    
    
        public AppDatabase(Context context) {
            super(context, DATABASE_NAME, null, DATABASE_VERSION);
        }
    }
    

    Increase this DATABASE_VERSION value if any alterations are done.

提交回复
热议问题