how should I open and close my database properly

前端 未结 5 1648
挽巷
挽巷 2021-02-06 06:39

I have an app which stores some data in a SQLite DB.Also I\'m doing a lot of query an requery in my app.I have about 15 activities in it.And almoust all use the DB to query for

5条回答
  •  生来不讨喜
    2021-02-06 07:27

    If you are not managing your database in line with Google's recommendations, why not - there's usually a good reason why things are the way they are...

    In any case, you can use getReadableDatabase() and getWriteableDatabase() - these functions will open the database if necessary, but just return the existing database object if it is already open, thus preventing you from opening the database multiple times.

提交回复
热议问题