在使用TextView显示消息时抛出致命错误。我使用此程序 我也设置了一些loger。它运行良好,直到logger =“lastmark”。
private void displayText(String message){
logger.info("inside display message");
TextView textView = (TextView)findViewById(R.id.name_1);
logger.info("last mark");
textView.setText(message);
}
public void callStatus(){
logger.info("inside 3 rd step");
dataBase = DataBaseManager.instance();
logger.info("inside 4 rd step");
//to get data from database we need a cursor.
//after we perform a select query all the data from database specific for the query, will be in the cursor
// "*" means "all" in translation the query means "SELECT ALL FROM NAME TABLE"
cursor = dataBase.select("SELECT * FROM " + TABLE_NAME);
logger.info("inside 4b rd step");
String s ="";
logger.info("inside 5 rd step");
//the cursor iterates the column "name"
while (cursor.moveToNext()){
do{
//in this string we get the record for each row from the column "name"
logger.info("inside 6 rd step");
String s1 = cursor.getString(cursor.getColumnIndex(COLUMN_NAME1));
String s2 = cursor.getString(cursor.getColumnIndex(COLUMN_NAME2));
s = s1+s2;
}while (cursor.moveToNext());
logger.info("inside 7 rd step");
//in this textView will be added, updated or deleted the string
// "\n" means "new line"
}
//here we close the cursor because we do not longer need it
cursor.close();
logger.info("inside 8 rd step");
displayText(s);
}
}
....在使用TextView显示消息时抛出致命错误。我使用此程序 我也设置了一些looger。它运行良好,直到logger =“lastmark”。
答案 0 :(得分:1)
试试这个:
创建光标后
if (cursor.moveToFirst())
{
do
{
// get column1 and column2
....
} while (cursor.moveToNext())
}
确保在所有光标操作后关闭光标。
答案 1 :(得分:0)
我知道,在while(cursor.moveToNext()){......}之前,你应该将光标移到第一个 必须首先执行cursor.moveToFirst()!