Cursor cursor = db.rawQuery("select * from sentmessages", null);
/*cursor.moveToFirst();
dataToInsert = dataToInsert + cursor.getString(1) + '\n';*/
cursor.moveToFirst();
dataToInsert = dataToInsert.concat(String.valueOf("aaaa")).concat(String.valueOf("\n"));
String dataToInsert = "";
cursor.moveToFirst();
dataToInsert = dataToInsert.concat(String.valueOf("bbbb")).concat(String.valueOf("\n"));
cursor.moveToFirst();
dataToInsert = dataToInsert.concat(String.valueOf("cccc")).concat(String.valueOf("\n"));
cursor.moveToFirst();
dataToInsert = dataToInsert.concat(String.valueOf("dddd")).concat(String.valueOf("\n"));
shdb.setText(dataToInsert);
下面的代码显示
aaaa和......
我要替换哪些代码才能显示
aaaa,bbbb,cccc,dddd
答案 0 :(得分:1)
用此替换您的代码并尝试
Cursor cursor = db.rawQuery("select * from sentmessages", null);
String dataToInsert = "";
cursor.moveToFirst();
dataToInsert = dataToInsert.concat(String.valueOf("aaaa")).concat(String.valueOf(", "));
cursor.moveToFirst();
dataToInsert = dataToInsert.concat(String.valueOf("bbbb")).concat(String.valueOf(", "));
cursor.moveToFirst();
dataToInsert = dataToInsert.concat(String.valueOf("cccc")).concat(String.valueOf(", "));
cursor.moveToFirst();
dataToInsert = dataToInsert.concat(String.valueOf("dddd")).concat(String.valueOf(", "));
shdb.setText(dataToInsert);