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

Database Is Locked #64

Open
asanchez128 opened this issue Aug 20, 2019 · 3 comments
Open

Database Is Locked #64

asanchez128 opened this issue Aug 20, 2019 · 3 comments

Comments

@asanchez128
Copy link

I use Monkey Cache to get data for two fragments that are displayed on a tab layout with a viewpager. Both fragments are loaded at the same time even though only one is visible at any given time. However, I get a "Database Is Locked" error in Crashlytics.

I quick workaround that came to mind was to just load one fragment at a time. However, both fragments have to be loaded for the sake of showing a sliding animation.

Perhaps using a singleton with locking for accessing Monkey Cache could also alleviate the problem.

Thank you for your help.

@jamesmontemagno
Copy link
Owner

Which monkey cache are you using? Sqlite? You could use a lock around your own access to it, however I do lock on most implemenations.

@asanchez128
Copy link
Author

Thank you @jamesmontemagno for your reply. Yes, I'm using the Sqlite implementation. I ended up writing code to access the MonkeyCache just when the the property UserVisibleHint in the fragment is set to true.

public override bool UserVisibleHint
        {
            get { return base.UserVisibleHint; }
            set
            {
                base.UserVisibleHint = value;
                if (UserVisibleHint)
                {
                   // call MonkeyCache
                }
            }
        }

Thanks a lot for MonkeyCache!

@jamesmontemagno
Copy link
Owner

Do you have a sample before of what was causing issues?

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

2 participants