jeudi 9 avril 2015

How to set ID of records in sqlite to position/id of Navigation Drawer item

I have 2 array that fetch from 2 column of my table in sqlite database.


1 - Group ID


2 - Group Name


I want create Navigation Drawer with Group name that when user click on each item I can get Group ID from position/id



final SQLiteDatabase mydatabase = openOrCreateDatabase("CopyCollection", MODE_PRIVATE, null);
Cursor crs = mydatabase.rawQuery("SELECT * FROM Groups WHERE ID != 1",null);
String[] array = new String[crs.getCount()];
String[] arrayID = new String[crs.getCount()];
int i = 0;
while(crs.moveToNext()){
String uname = crs.getString(crs.getColumnIndex("GroupName"));
String id = crs.getString(crs.getColumnIndex("ID"));
array[i] = uname;
arrayID[i] = id;
i++;


Now I have 2 array but I don't know how can I set in Navigation Drawer



public void onItemClick(AdapterView<?> parent, View view, final int pos, final long id){

Aucun commentaire:

Enregistrer un commentaire