Android SQLite是线程安全的吗?
来源:互联网 发布:数据库性能测试 编辑:程序博客网 时间:2024/05/16 09:49
本文转载自
SQLite数据库本身不具有线程安全性
Android SQLiteDatabase提供了线程安全的保证,里面添加了同步逻辑。
http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#setLockingEnabled%28boolean%29
http://stackoverflow.com/questions/6675240/is-sqlite-database-instance-thread-safe
我们操作数据库一般使用ContentProvider,SQLiteOpenHelper,应用中使用SQLiteDatabase db = SQLiteOpenHelper.getReadableDatabase(),这个db需要调用db.close()或者openHelper.close()方法吗?
不需要。
为什么?
http://stackoverflow.com/questions/4547461/closing-the-database-in-a-contentprovider?lq=1
ContentProvider随它的宿主进程创建,与该进程有相同的生命周期,所以不需要手动去关闭,在内核清理进程资源的时候会将它一起清理,也就是这时候关闭的。
A content provider is created when its hosting process is created, and remains around for as long as the process does, so there is no need to close the database – it will get closed as part of the kernel cleaning up the process’s resources when the process is killed.
- Android SQLite是线程安全的吗?
- Android SQLite是线程安全的吗?
- Android SQLite是线程安全的吗?
- Android中Handler线程的处理是线程安全的
- log4j是线程安全的吗?
- servlet是线程安全的吗
- servlet默认是线程安全的吗
- Servlet是线程安全的吗?
- springMVC是线程安全的吗?
- Connection实例是线程安全的吗
- Servlet是线程安全的吗?
- servlet是线程安全的吗?
- servlet是线程安全的吗
- servlet是线程安全的吗?
- malloc是线程安全的吗
- Connection实例是线程安全的吗
- Connection实例是线程安全的吗
- Servlet是线程安全的吗?
- Day2JavaScript
- 程序员必会的经典排序算法(三)插入排序
- 文章标题
- in操作符检查属性
- HDU 2090
- Android SQLite是线程安全的吗?
- [C]m*n矩阵划分成k*j等份
- Intent(二)隐式调用intent
- 08 JavaScript基础之--冒泡排序
- Java学习笔记--类与对象
- 【Hacker Rank】01.Say "Hello, World!" With Python
- Flask返回二进制图片
- 一些JAVA-Swing-JFream常用到的功能
- HDU 2089