2011-02-03 74 views
0

我有一个有趣的问题,我的手机上的代码运行良好,但是在模拟器上运行时,一旦应用程序试图从数据库获取值,就会发生崩溃。模拟器中的Android SQLite崩溃,但没有电话?

这里是一个崩溃它

/** 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; 

} 

的DB辅助功能,它抛出的错误是:

getWriteableDatabase()的递归调用。

+1

请给我们一个完整的堆栈跟踪。 – 2011-02-03 01:17:54

回答

0

比较遗憾的是,问题是,我试图仍然编辑表中onCreate()方法导致getWrteableDatabase()递归调用。

它没有在模拟器上工作,但在手机上工作的原因是因为在将任何内容添加到onCreate之前,数据库已在手机上创建,但在其他设备上部署会导致崩溃。

相关问题