Answer the question
In order to leave comments, you need to log in
How to work with sqlite from multiple threads in android?
Hello dear hackers.
I am writing out of desperation.
I am developing an application that writes data to the database in several threads.
When a second vustream is attached for writing or reading, an error occurs that some cursor has not been closed.
Please tell me how to work with sqlite in android with several threads.
Maybe someone has experience of circumventing this problem
I would be very grateful for any help.
PS I know how sqlite works, and I know that opening a file for writing is blocked, I'm interested in how to create a queue or something like that
Answer the question
In order to leave comments, you need to log in
Make yourself a class xxxApplication extends Application, write it in the manifest.
And in it make one connection to the database. There is only one Application class in the android program, so all variables are there as singleton.
I'm not much of an Android expert, but I think you should read up on thread synchronization and POSIX.
How many streams are planned? Maybe it's better to make a thread that works with the base, and the rest access it?
I would make an adapter that sucks data from different streams into itself and organizes a queue. And communication with a DB would conduct only by means of this adapter.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question