android - How to get random data in SQLite? -
i trying random order using order newid()
following:
public cursor getspeciallist(string bloodcategory) { sqlitedatabase db = this.getreadabledatabase(); cursor cur = db.rawquery("select " + colname + " ," + "" + colfather + " ," + "" + colfamily + " ,"+ "" + colphone + " " + listinfotable + " " + colbloodcategory + "='" + bloodcategory + "'" + " order newid() ", new string[]{}); return cur; }
sqlite log gives me following error:
no such function newid
you can use following code random data:
public cursor getspeciallist(string bloodcategory ) { sqlitedatabase db=this.getreadabledatabase(); cursor cur=db.rawquery("select "+colname+" ,"+ ""+colfather+" ,"+ ""+colfamily+" ,"+ ""+colphone+" "+listinfotable+ " "+colbloodcategory+"='"+bloodcategory+"'"+ " order random() ",new string[] {}); return cur; }