android - How to sort a cursor based on a time string -
my question if simple, have segment of code
cursor mcursor = this.getcontentresolver().query( playercontentproviderdb.content_uri, fulldatacolumns, null, null, players.score +" asc");
this code, i've seen, should sorting cursor in ascending order based on players.score not.
for reference players.score string in format mm:ss:msmsms ( read minute:second:millisecond).
also here code query method in contentprovider
public cursor query(uri uri, string[] projection, string selection, string[] selectionargs, string sortorder) { sqlitequerybuilder querybuilder = new sqlitequerybuilder(); checkcolumns(projection); querybuilder.settables(playercontract.players.players_table_name); int uritype = surimatcher.match(uri); switch (uritype) { case all_scores: break; case score_id: querybuilder.appendwhere(playercontract.players.id + "=" + uri.getlastpathsegment()); break; default: throw new illegalargumentexception("unknown uri: " + uri); } sqlitedatabase db = this.dbhelper.getreadabledatabase(); cursor cursor = querybuilder.query(db, projection, selection, selectionargs, null, null, sortorder); // notify potential listeners cursor.setnotificationuri(getcontext().getcontentresolver(), uri); homecoming cursor;
my question why dose code not work , how can prepare it?
(another interesting note code trying add together limit statement end of sort, have read works, mine not)
if reading the sqlite documentation correctly, date()
expects value of form %y-%m-%d
. yours not.
if using two-digit min , sec values, should sort without function.
(above original question, not update)
also, querying contentprovider
. there no requirement contentprovider
offer sorting. if own contentprovider
, need check on side whether or not passing sort clause on sqlite or whatever backing store is.
android sorting android-cursor
No comments:
Post a Comment