Hi Kostya, Thanks
I have change code like this:
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
sampleDB = this.openOrCreateDatabase(SAMPLE_DBNAME,
MODE_PRIVATE, null);
Cursor groupCursor = sampleDB.rawQuery ("SELECT _id,
RoomName ,SwitchFullName FROM SwitchTable GROUP BY RoomName",null);
System.out.println ("#######"+groupCursor.getCount());
System.out.println ("_____"+groupCursor.getPosition());
System.out.println (groupCursor.getColumnIndex("RoomName"));
// Cache the ID column index
mGroupIdColumnIndex =
groupCursor.getColumnIndexOrThrow("_id");
//groupCursor.moveToFirst();
// Set up our adapter
mAdapter = new MyExpandableListAdapter(groupCursor,
this,
android.R.layout.simple_expandable_list_item_1,
android.R.layout.simple_expandable_list_item_2,
new String[] {"RoomName"}, // Name for group layouts
new int[] {android.R.id.text1},
new String[] {"SwitchFullName"}, // Number for child
layouts
new int[] {android.R.id.text1});
setListAdapter(mAdapter);
System.out.println ("%%%%
%"+getExpandableListAdapter().getGroupCount());
System.out.println ("::::::::::::::"+this.getSelectedId());
}
Now I want name of parent (here name of room) on which user clicked.
Because if I get name of room then I can use that in getChildrenCursor
() as
protected Cursor getChildrenCursor(Cursor groupCursor)
{
Cursor groupCursor1 = sampleDB.rawQuery ("SELECT
_id,SwitchFullName FROM SwitchTable where RoomName = 'HERE GOES ROOM
NAME'",null);
//System.out.println ("#######"+groupCursor1.getCount());
return groupCursor1;
}
So how to get room name.Thanks
On Dec 15, 4:55 pm, Kostya Vasilyev <[email protected]> wrote:
> 15.12.2010 14:05, pramod.deore пишет:
>
> > Hi every time I get _ID value as 1. I used following line to get
> > value
> > mGroupIdColumnIndex = groupCursor.getColumnIndexOrThrow("_id");
>
> That's the index of column "_ID" within your query, not the value stored
> in the database.
>
> http://developer.android.com/reference/android/database/Cursor.html#g...)
>
> > And you told me that usethis is in where condition into following
> > query.
>
> > Cursor groupCursor1 = sampleDB.rawQuery ("SELECT DISTINCT
> > RoomName AS RoomName1 ,_id , SwitchFullName FROM SwitchTable ORDER BY
> > RoomName",null);
>
> See last parameter:
>
> http://developer.android.com/reference/android/database/sqlite/SQLite...,
> java.lang.String[])
>
> Also:
>
> http://www.sqlite.org/lang_select.html#whereclause
>
> --
> Kostya Vasilyev -- WiFi Manager + pretty widget
> --http://kmansoft.wordpress.com
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en