Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProviGenProvider uses onCreate() method to initialise database -> causes ANR #42

Open
pstambrecht opened this issue Sep 30, 2020 · 0 comments

Comments

@pstambrecht
Copy link

pstambrecht commented Sep 30, 2020

ProviGenProvider uses onCreate() method to initialise SQLiteOpenHelper which causes ANR error.

  @Override
    public boolean onCreate() {
        openHelper = openHelper(getContext());
     ...
    }

Due to Android ContentProvider documentation onCreate() method runs on main thread and "It must not perform lengthy operations, or application startup will be delayed." .

From documentation:
"You should defer nontrivial initialization (such as opening, upgrading, and scanning databases) until the content provider is used (via query(Uri, String[], Bundle, CancellationSignal), insert(Uri, ContentValues), etc)."

https://developer.android.com/reference/android/content/ContentProvider#onCreate()

What about to initialise SQLiteOpenHelper lazily from other methods such a query, insert and so on?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant