Siemka,
Mam Problem, chciałbym wyciągnąć z bazy konkretną kolumnę i wstawić ją do ListView. Problem taki, że gdy baza jest pusta lub są tam elementy które nie spełniają kryterium zapytania to ListView zgodnie z planem jest pusta, zaś gdy powinna coś wyświetlić to wyrzuca mnie z aplikacji a Logcat nie pokazuję żadnych błędów. Ktoś widzi błąd ?
//Kod w DatabaseHelper ===================================================
public Cursor getdByStatus(String wantedStatus)
{
SQLiteDatabase db = this.getWritableDatabase();
String query = "select id from "+TAB_CUSTOMERS+" where id= '"+wantedStatus+"'";
Cursor data = db.rawQuery(query,null);
return data;
}
//Kod w klasie ===========================================================
packList = (ListView)findViewById(R.id.ID_PACK_LIST);
dbH = new DatabaseHelper(this);
Cursor data = dbH.getByStatus("1");
ArrayList<String> list = new ArrayList<>();
if( data.getCount() == 0){
Toast.makeText(StorehouseActivity.this,"Empty",Toast.LENGTH_LONG).show();
}
else{
while(data.moveToNext()){
list.add(data.getString(1));
ListAdapter arrayAdapter = new ArrayAdapter<>(this,android.R.layout.simple_expandable_list_item_1,list);
packList.setAdapter(arrayAdapter);
}
}