在Android上的SQLite忙碌超时 [英] Busy timeout for SQLite on Android
本文介绍了在Android上的SQLite忙碌超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何增加Android上SQLite的忙碌超时?
当两个线程同时试图插入一些数据到数据库,这将是非常有用,并抛出异常:
android.database.sqlite.SQLiteException:错误code 5:数据库被锁定。
解决方案
您应该SQLiteOpenHelper的一个实例,然后它的作品。
<一个href=\"http://stackoverflow.com/questions/2493331/what-is-best-practice-with-sqlite-and-android/3689883#3689883\">The回答这也解释了它
How to increase the busy timeout for the SQLite on Android ? It would be useful for situations when two threads are simultaneously trying to insert some data to DB and exception is thrown:
android.database.sqlite.SQLiteException: error code 5: database is locked.
解决方案
You should have one instance of SQLiteOpenHelper then it works.
这篇关于在Android上的SQLite忙碌超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文