i got a problem with SQLite tables and a listview. I have implemented a db including tables and data and can display them in a listview. I want to edit the entries which is working well too. Only the ordering isn't as good as i want it.
When i want to show my entries ordered by column 1
or column 2
and edit the entry after that, i have the problem, that i used the position in the list for the position in the table (with cursor.moveToNext()
for x
times).
Now i solved it with reading out the whole table with
SELECT * FROM table ORDER BY column
Deleting and refilling the table with the ordered data. Then read out again and display it.
But this isn't a good neither a secure way to do it. If the app crashes while it's doing some work i could lose data. Is there a good way to get a reference where i have to edit in the listview without displaying it? Or should i work with custom ListView-layouts and an extra data class for the listview so i don't have to edit the whole db, just edit the data and after editing i rewrite it to the point in the database?
I didn't find a function for something like that in the SQLite doc. But maybe i didn't looked deep enough.
Thanks!