After querying the data that I wanted, now I have a cursor containing all the data presented to the user in Listview.
When a user clicks on an item to edit it, I move the cursor to the desired position cursor.moveToPosition(pos) , from which I can get all the necessary data for the item: identifier, title, folder or not, parent folder.
Now that I have the parent folder identifier, how can I use it to get the title of the folder with the items so that I can show the user in which folder the given item is in? I cannot use the move to position, because I do not know the parent position, but only its identifier.
Here is an example db.
FOLDER column β 0 = not folder (false), 1 = folder (true)
PARENT β contains its folder identifier
ID TITLE FOLDER PARENT 1 folder1 1 0 2 item1 0 1 3 item2 0 1 4 folder2 1 1 5 item1 0 4 6 item2 0 4 7 folder3 1 4 8 item1 0 7 9 item2 0 7
Example: A user edits item3. I move the cursor to position 2 (starting from 0). I get the parent element3, which is equal to ID = 1. How can I get TITLE ID = 1.
Hope this is clear enough :) Thanks!
source share