How to use my own sqlite database?

后端 未结 7 509
隐瞒了意图╮
隐瞒了意图╮ 2020-12-02 15:20

I put my database field in \"assets\" folder. And use the code from this blog to copy the database to \"/data/data/my_packname/databases/\", (This copy code i run it in the

7条回答
  •  Happy的楠姐
    2020-12-02 15:26

    The way of creating database from article you've posted is slightly diffrent from that how it's done in android examples (I don't want to say if it's good or bad).

    I've learned how to use databases from SDKs NotePad sample

    It's good example to start from, becouse it covers both database creation topic and database access through ContentProvider (it's really the only good way to get data from db, otherwise you will have problems when trying to get data simultaneusly from many places of your code).

    You should note that SQLiteOpenHelper is really powerful and "it will help you" if you will use it properly. For example it stores current database version (not sqlite version but number you assingn with database schema version) and when you create new application version with new database structure you can update current schema to the new version in onUpdate.

提交回复
热议问题