Android Content Provider database leak issue

后端 未结 3 1981
执念已碎
执念已碎 2020-12-13 05:08

I am writing a content provider for this application and in my content provider I am opening a database connection, running a query and returning the cursor of results to th

3条回答
  •  萌比男神i
    2020-12-13 05:23

    You're not missing anything AFAIK. Android is missing an onDestroy() (or the equivalent) for ContentProvider. There isn't even anything in the source code in this area that suggests there is some sort of onDestroy() that just isn't surfaced in the SDK.

    If you look at the source code for AlarmProvider and LauncherProvider, they even create database objects on a per-API-call basis (e.g., every time they get insert(), they open a writable database handle that they never close).

提交回复
热议问题