我遇到了一个有趣的问题,我的代码在手机上运行良好,但是在模拟器上运行时,一旦应用程序尝试从数据库中获取值,我就会崩溃。
这是导致它崩溃的 DB Helper 函数
/** Used to retrieve our lowest stored val */
public int GetLowestVal(){
// Get our databases results
Cursor result = null;
try {
// Get our databases results
result = super.getAll();
} catch( SQLException anyDbError ) {
// Errors? TODO
} finally {
// Finally TODO
}
// Setup initial lowest val
int lowestVal = 0;
// Move through results and compare them
while( result.moveToNext() ){
// Get our place from the DB
int index = Integer.parseInt(result.getString(1).trim());
// Last index should be lowest
if ( index == 10){
lowestVal = Integer.parseInt(result.getString(3).trim());
}
}
// Return our value
return lowestVal;
}
它抛出的错误是:
getWriteableDatabase() 被递归调用。