getDatabase called recursively数据库递归使用错误---解决方法
来源:互联网 发布:sql多个统计结果 编辑:程序博客网 时间:2024/05/22 06:17
@Overridepublic void onCreate(SQLiteDatabase db) { // Create tables db.execSQL(CREATE_CATEGORIES_TABLE); db.execSQL(CREATE_CHRGDATA_TABLE); db.execSQL(CREATE_SETTINGS_TABLE); setDefaultLabel();}/** * */public void setDefaultLabel() { // create default label SQLiteDatabase db = this.getWritableDatabase(); ContentValues values = new ContentValues(); values.put(KEY_NAME, "Default"); db.insert(TABLE_LABELS, null, values);}
代码中onCreate方法中的setDefaultLabel()方法里再次调用了SQLiteDataabase造成,数据库递归调用,此时的解决办法为:修改setDefaultLabel()方法
@Overridepublic void onCreate(SQLiteDatabase db) { // Create tables db.execSQL(CREATE_CATEGORIES_TABLE); db.execSQL(CREATE_CHRGDATA_TABLE); db.execSQL(CREATE_SETTINGS_TABLE); setDefaultLabel(db);}/** * */public void setDefaultLabel(SQLiteDatabase db) { // create default label ContentValues values = new ContentValues(); values.put(KEY_NAME, "Default"); db.insert(TABLE_LABELS, null, values);}此时,SQLiteDatabase引用之前参数中的,就避免了重复。
其他情况类似,请根据此方法为蓝本,进行改造即可。。。。
1 0
- getDatabase called recursively数据库递归使用错误---解决方法
- getDatabase called recursively
- java.lang.IllegalStateException:getDataBase called recursively
- getWritableDatabase called recursively
- java.lang.IllegalStateException: getWriteableDatabase called recursively
- Reset-floppy called错误和Bad partition table错误解决方法
- getWritableDatabase called recursively;bind or column index out of range
- SQLite报错:getWritableDatabase called recursively的解决
- 递归翻转string Reverse a String recursively
- 类似错误: 找不到符号 符号: 方法 getDatabase() 位置: 类 Connector
- R6010 -abort() has been called错误分析及其解决方法
- R6010 -abort() has been called错误分析及其解决方法
- R6010 -abort() has been called错误分析及其解决方法
- mysql数据库错误解决方法
- Java插入排序递归算法(insert sorting recursively)
- 算法导论(build the heap recursively 递归建堆)
- 关于R6010 -abort() has been called的错误分析及其解决方法
- 使用FABridge时,出现You are trying to call recursively into the Flash Player which is not allowed…错误的处理
- Stackoverflow每日问题 系列前言
- 序号互换
- 移动端与PHP服务端接口通信流程设计(增强版)
- Window下开发环境安装和Hello World
- ios-day15-04(Quartz 2D之屏幕截图、并将截图保存到文件中)
- getDatabase called recursively数据库递归使用错误---解决方法
- [LeetCode 28]Implement strStr()
- 《数据结构编程实验》 3.3.1Symmetric Order
- hostapd 与 wpa_supplicant详解
- COCOS-Tiled地图类
- null和undefined
- [Codeforces #296 div1]简要题解
- 运维自动化
- 了解mock