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

最佳答案

以此替换您的代码,然后尝试

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);

10-07 15:27