Managing SQLite Connections in Android

前端 未结 2 1063
攒了一身酷
攒了一身酷 2020-12-30 03:25

I have a (hopefully) quick question regarding handling SQLite database connections in Android. I have an app that is composed, naturally, of several activities. I have no tr

2条回答
  •  有刺的猬
    2020-12-30 04:13

    Just use SQLiteOpenHelper.getReadableDatabase() and SQLiteOpenHelper.getWriteableDatabase() - Android will manage and cache the connection so you don't need to.

    In fact, refer to the official Google Using Databases documentation:

    To write to and read from the database, call getWritableDatabase() and getReadableDatabase(), respectively. These both return a SQLiteDatabase

提交回复
热议问题