How to transform a Cursor into a String?

0

Hello, I need to figure out how to transform a Cursor with data coming from the Android Internal Database (SQLite) into a String or String Array.

I've tried it in some ways, but none of it has worked.

String lista = "Lista de Compras \n\n";
for (int i = 0; i <= cursor.getColumnCount(); i++){
    lista.concat(cursor.getString(i)+ "\n");
}

And in the Database:

public Cursor buscaListaProdutos(){
    SQLiteDatabase banco = getWritableDatabase();
    Cursor c = banco.rawQuery("SELECT _id, nomeProduto, qtdeProduto FROM listaProduto", null);

    if(c.moveToFirst()){
        banco.close();
        return c;
    }else{
        banco.close();
        return null;
    }
}
    
asked by anonymous 24.11.2017 / 19:42

0 answers