Refresh/Reload database reference in custom ContentProvider after restore

前端 未结 4 1466
失恋的感觉
失恋的感觉 2020-12-16 21:57

I use a ContentProvider in my app and everything works great except for one little issue. I have a backup and restore function that backs up the database to a file on the SD

4条回答
  •  余生分开走
    2020-12-16 22:49

    Are you maintaining a reference to the actual SQLiteDatabase in your content provider (something like calling SQLiteOpenHelper.getWritableDatabase() in onCreate() and then keeping that reference)? Or do you get the DB object from someplace like a helper in each provider method?

    Typically, if you only keep a local reference to the helper and get the writable/readable database instance inside of each method as needed then this problem should go away. If not, perhaps we can take a look at the provider code?

    Hope that Helps!

提交回复
热议问题