I replaced sqlite with realm in my open source Linux Command Library project. Everything went fine so far, but now I'm facing a problem.
I'm using a RealmBaseAdapter to display all the commands in a ListView with an search interface. For a search the realm sniped below orders the results like this:
Query: test
result:
- l2test
- rctest
- test
-
testparm
RealmResults<Command> commands = mRealm.where(Command.class).contains("name", query).findAll(); mAdapter.updateRealmResults(commands);
With the old sqlite logic the order was like this:
result:
- test
- testparm
- l2test
- rctest
return getReadableDatabase().rawQuery("Select * from " + CommandsDBTableModel.TABLE_COMMANDS + " WHERE " + CommandsDBTableModel.COL_NAME + " LIKE '%" + query + "%' " + "ORDER BY " + CommandsDBTableModel.COL_NAME + " = '" + query + "' DESC," + CommandsDBTableModel.COL_NAME + " LIKE '" + query + "%' DESC", null);
Is it possible to realize it with realm too? Here is the link to the project http://ift.tt/1SrM37z
Aucun commentaire:
Enregistrer un commentaire