Populating ExpandableListview from SQLite

Views: 8164  |   Date: 2014-01-19 12:16:36

I am using the code you create here http://androidexample.com/LISTVIEW/index.php?view=article_discriptdion&aid=107&aaid=129. It's working great so far, but I am having one issue getting the data to come from SQLlite just for the Parent and keep all the graphics the same. Do you have any sample code you can provide to do that. So far, I have create a databasehelper.

Here is what I done so far. Thanks for your help.

/** HELPER CODE ******************
* getting all saveNames into an ArrayList
* */
public ArrayList getSaveNamesArrayList() {
ArrayList saveNamesArrayList = new ArrayList();
String selectQuery = "SELECT * FROM " + TABLE_SAVENAMES;
Log.e(LOG, selectQuery);

SQLiteDatabase db = this.getReadableDatabase();
Cursor c = db.rawQuery(selectQuery, null);

// looping through all rows and adding to list
if (c.moveToFirst()) {
do {
saveNames td = new saveNames();

// adding to saveNames list
} while (c.moveToNext());

return saveNamesArrayList;


***** CALL TO HELPER CODE *****************

//Creating static data in arraylist
final ArrayList dummyList = buildDummyData();
// Adding ArrayList data to ExpandableListView values

* here should come your data service implementation
* @return
private ArrayList buildDummyData() {
// Creating ArrayList of type parent class to store parent class objects
ArrayListlist=new ArrayList();
//final ArrayList list = new ArrayList();
db = new DatabaseHelper(getApplicationContext());
//ArrayListlist=new ArrayList();
list = db.getSavedNamesArrayList();
return list;

Submit Your Answer

Preview :