SQLite db example:
** I don’t create the db, it’s Android Bookmarks db, which I access using contentproviders.
** from what I understand after some searches, SQLite doesn’t support foreign key constraints but triggers are possible – http://www.sqlite.org/cvstrac/wiki?p=ForeignKeyTriggers
FOLDER column -> 0 = not a folder (false), 1 = a folder (true)
PARENT column -> holds the ID of its folder
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
…and so on
On my Android app, I’m trying to recursively delete items from a SQLite db.
I have the ID of the first folder and I want to loop to find all it’s inner items (more folders and items).
For example – I have ID=1, so I can easily delete IDs 2 and 3 by requesting a query of all items their parent is ID=1, get items IDs and then delete.
The problem is I can’t figure out how to delete ID=4 and its inner items (item1, item2, and folder3) and then folder3 inner items.
Would love some help with this! been trying for hours :\
Thanks!
If in java then something like this I think, I think functions like
findNextChildIdshould not be a problem: