Android : Show SQLite data in ListView

on Friday, August 29, 2014


I'm trying to show data from SQLite in listview.


There's no error on my code but I got this as a result


enter image description here


Here's my code.



DatabaseHandler db = new DatabaseHandler(this);

/**
* CRUD Operations
* */
Log.d("Reading: ", "Reading all contacts..");
List<AllItem> allItems = new ArrayList<AllItem>();

allItems = db.getAllAccommodations();

for (AllItem cn : allItems) {
String log = "Table Id: "+cn.getTableID()+",Id: "+cn.getID()+" ,Name: " + cn.getCategory_name() + " ,Phone: " + cn.getItem_name();
// Writing Contacts to log
Log.d("Name: ", log);
}

ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, allItems);
listview.setAdapter(adapter);


How to get the real data from SQLite ?


Thanks before :D


0 comments:

Post a Comment