开发者

Is it neceassry to extends SQLiteOpenHelper?

Is it necessary to extends SQLiteOpenHelper.I just want to copy the database(read only) f开发者_JAVA技巧rom aseets folder.


It is not necessary to extends SQLiteOpenHelper,To create and upgrade a database in your Android application you usually subclass "SQLiteOpenHelper". In this class you need to override the methods onCreate() to create the database and onUpgrade() to upgrade the database in case of changes in the database schema. Both methods receive an "SQLiteDatabase" object.

SQLiteOpenHelper provides the methods getReadableDatabase() and getWriteableDatabase() to get access to an "SQLiteDatabase" object which allows database access either in read or write mode.

For the primary key of the database you should always use the identifier "_id" as some of Android functions rely on this standard.


if you just want to copy the database then its fine. But if you want to read,update,delete or create new record in database then there are two ways

  1. Extend sqlitedatabase
  2. Use ormlite wrapper

Hope this will help.


Yes, it not need ,if you just want copy database file and don`t operate database, it just a file I/O operate.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜