android can single instance of SQLiteDatabase manage synchronization between multiple threads?

心已入冬 提交于 2020-01-04 14:27:54

问题


I need to do writing into the database from different AsyncTask threads but the problem is that we need to be sure that at one time only one thread should be in the process of writing into the db? My question is if i use the singleton pattern in making the single instance of SQLiteDatabase object all over the application,will that single instance manage the synchronization between different threads or not ? Thanks


回答1:


My question is if i use the singleton pattern in making the single instance of SQLiteDatabase object all over the application,will that single instance manage the synchronization between different threads or not ?

Yes, it will.



来源:https://stackoverflow.com/questions/17674182/android-can-single-instance-of-sqlitedatabase-manage-synchronization-between-mul

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!