I need to save the names of the users table in a list and save them in an ArrayList. I did this:
public List<String> buscarUsuarios() {
List<String> nomes = new ArrayList<String>();
String selectQuery = "select nome from usuarios";
Cursor cursor = db.rawQuery(selectQuery, null);
if (cursor.getCount() > 0) {
cursor.moveToFirst();
do {
cursor.moveToFirst();
String nomeString = cursor.getString(cursor.getColumnIndex("nome"));
StringBuilder conversor = new StringBuilder();
conversor.append(nomeString);
nomes.add(conversor.toString());
} while (cursor.moveToNext());
}
return nomes;
}
But it's giving infinite looping Can anyone help me?