Here is the context: I have an SQLite table Task, and I would like to display the 5 tasks with the highest "priority" in a ListView.
Priority is a complex calculation, so I can't just compute it in SQL and order/limit the result.
To achieve that goal, I was thinking about getting a Cursor with all the tasks, going through the rows to compute and set a "priority" number, and delete/reorder the rows of the cursor so that it shows only the first 5.
From what I found, I can set a "priority" value to a row by extending Cursor so that it exposes CursorWindow.
Unfortunately, I haven't found a way to alter the rows of the Cursor to delete/order them.
Is there a way to do that? If not, I'm also open to other efficient design alternatives.
Of course, I could add a "priority" column in my table, update it every time, and then do the selection with order/limit, but that's not very efficient.
Thanks!
Aucun commentaire:
Enregistrer un commentaire