I am trying to get data from database to arraylist and then show them. Unfortunately I get this
error:java.lang.OutOfMemoryError: OutOfMemoryError
thrown while trying to throw an exception; no stack trace available. I am using own class for Object, which are store in database.
MainActivity code:
narodyList = db.getVsechnyNarody();
String k = narodyList.get(1).toString();
Toast.makeText(getApplicationContext(),"Záznam" + k,Toast.LENGTH_LONG).show();
DatabaseHandler.java:
public List<Narody> getVsechnyNarody(){
List<Narody> narodyList = new ArrayList<Narody>();
String selectQuery = "SELECT * FROM " + TABLE_NARODY;
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
if(cursor.moveToFirst()){
do {
Narody narod = new Narody();
narod.setId(Integer.parseInt(cursor.getString(0)));
narod.setNazevNaroda(cursor.getString(1));
narodyList.add(narod);
} while (cursor.moveToFirst());
}
cursor.close();
db.close();
return narodyList;
}