Sunday 11 May 2014

Get category id

private String GetCategory(){
String category_id="";
OpenDatabase();
Cursor c = mDbHelper.GetSelectedCategoryList(mSQLiteDatabase, 1);
if(c!=null){
    if(c.getCount() > 0){
    c.moveToFirst();
    int i=0;
while(c.isAfterLast() == false){
if(i==0){
category_id="" +c.getInt(0);
}
else{
category_id=category_id+","+c.getInt(0);
}

if(i==c.getCount()-1){
category_id=category_id + "";
}
i++;
c.moveToNext();
};
    }
    c.close();
}
CloseDataBase();
return category_id;
}

No comments:

Post a Comment