How using SQLiteOpenHelper with database on sd-card?

后端 未结 6 829
渐次进展
渐次进展 2021-02-08 00:50

According to various answers here and in the web extending Application and it\'s inherited method getDatabasePath() would allow to set the database storage path from the standar

6条回答
  •  旧巷少年郎
    2021-02-08 01:17

    Calling this function will invoke the onCreate method in the SqliteOpen helper class

        public dbOperation open() throws SQLException 
        {
            db = DBHelper.getWritableDatabase();
            return this;
        }
    

    The oncreate method is like this

           public void onCreate(SQLiteDatabase db) 
            {
                try {
                    db.execSQL(DATABASE_CREATE);
    
                } catch (Exception e) {
                        e.printStackTrace();
                }
            }
    

    DATABASE_CREATE is the string which contain the query for creating database

提交回复
热议问题