I’m having an issue trying to load my database into an Android ExpandableList, I’ve tried using the CursorTree and SimpleCursorTree methods with minimal success, so now I’m trying to get it working with BaseExpandableListAdapter. For some reason all I get are the categories, but not the actual lists for the categories, what am I doing wrong?
public static String[][] sortSpellNames(){
int groupnmbr = 0;
int childnmbr = 0;
String[] aGroups = {"Combat", "Detection", "Health", "Illusion", "Manipulation"};
String[] Combat = new String[grabList("SHADOWRUNSPELLS",new String[]{"Name"}, "'Category' like 'Combat'").getCount()],
Detection = new String[grabList("SHADOWRUNSPELLS",new String[]{"Name"}, "'Category' like 'Detection'").getCount()],
Health = new String[grabList("SHADOWRUNSPELLS",new String[]{"Name"}, "'Category' like 'Health'").getCount()],
Illusion = new String[grabList("SHADOWRUNSPELLS",new String[]{"Name"}, "'Category' like 'Illusion'").getCount()],
Manipulation = new String[grabList("SHADOWRUNSPELLS",new String[]{"Name"}, "'Category' like 'Manipulation'").getCount()];
Cursor cursor;
while(groupnmbr < aGroups.length){
childnmbr = 0;
cursor = grabList("SHADOWRUNSPELLS",new String[]{"Name"}, "'Category' like '" + aGroups[groupnmbr] + "'");
cursor.moveToFirst();
while(cursor.moveToNext()){
switch(groupnmbr){
case 0: Combat[childnmbr] = cursor.getString(cursor.getColumnIndex("Name"));
break;
case 1: Detection[childnmbr] = cursor.getString(cursor.getColumnIndex("Name"));
break;
case 2: Health[childnmbr] = cursor.getString(cursor.getColumnIndex("Name"));
break;
case 3: Illusion[childnmbr] = cursor.getString(cursor.getColumnIndex("Name"));
break;
case 4: Manipulation[childnmbr] = cursor.getString(cursor.getColumnIndex("Name"));
break;
}
childnmbr++;
}
groupnmbr++;
}
String[][] aChildren = {Combat, Detection, Health, Illusion, Manipulation};
return aChildren;
}
I just worked out the problem. First the search needed \” surrounding the searches, instead of ‘. Then I ran into a null pointer exception which was resolved by changing
with
and repeated for each String[]. Hopefully this is helpful for anyone else that runs into a similar problem.