iI am developing a restaurant menu app in androidAndroid. My app has 1one database table which hashas the following columns id(primary key) ,category, item name. Category:
- id (primary key)
- category
- item name
The category column shows the category of item such as veg , non veg, snacks etc. It has duplicate values. i and I want to select only distinct values from this column. iI have tried raw query,the following but it is not working, plz help me. here is my raw query if anyone can provide a solution:
String query = "SELECT DISTINCT category FROM todo"; Cursor cursor = database.rawQuery(query,null); if (cursor != null) { cursor.moveToFirst(); } return cursor;