I am working on a little Android app, for the game EVE.
While working on the activity for adding new characters I created myself a class for database handling of all the CRUD operations and whatnot, which you can take a look at here, but most importantly what my issue is that the getAllCharacters() method returns and empty List.
public List<Character> getAllCharacters() {
List<Character> characterList = new ArrayList<Character>();
String selectQuery = "SELECT * FROM " + TABLE_CHARACTERS;
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
if (cursor.moveToFirst()) {
do {
Character character = new Character();
character.set_id(Integer.parseInt(cursor.getString(0)));
character.set_apiKey(cursor.getString(1));
character.set_keyId(cursor.getString(2));
} while (cursor.moveToNext());
}
return characterList;
}
Is the code itself in the method, and the way I am using it is
DatabaseHandler db = new DatabaseHandler(getApplicationContext());
List<Character> list = db.getAllCharacters();
and when trying to call toString() on it I get [] as a value.
I can see the entries to the database being made, as shown here.
Any help would be appreciated, cheers.
Aucun commentaire:
Enregistrer un commentaire