Thanks for your help. I have been reading various posts on the subject, but I feel I need to further clarify this.
In my app various threads access my db for read/write operations.
So: I understand that the SQLiteOpenHelper
must be only one across my application, and I use a singleton to deal with it, no problem.
But I have a Helper class that uses the SQLiteOpenHelper
sigleton to provide more encapsulated methods (like insertAllMyStuff(Stuff)
).
Now my doubts, regarding the Helper are the following:
- CAN I make the Helper and its methods static?
- SHOULD I make the Helper and its methods static?
- SHOULD I RATHER use a non static Helper class?
My concern is not corrupting the db (that won't happen since I hold always a single instance of the SQLiteOpenHelper
) BUT rather:
- will other wild things happen if I multiple threads access the same static methods? (like inserting
bar
instead offoo
, I am afraid yes) - if i use synchronized methods the app will slow down a lot.
Do I really NEED a ContentProvider to solve this??(I'd prefer not to use it)
Thanks
LISA
Aucun commentaire:
Enregistrer un commentaire