Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6783449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:51:55+00:00 2026-05-26T16:51:55+00:00

SQLite db example: ** I don’t create the db, it’s Android Bookmarks db, which

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:51:56+00:00Added an answer on May 26, 2026 at 4:51 pm

    If in java then something like this I think, I think functions like findNextChildId should not be a problem:

     deleteFolderAndSub(int id){
            int childId = findNextChildId(id);
             //Let -1 be that there are no more children
            while (childId!=-1){
            if (checkIfFolder(childId)){
                deleteFolderAndSub(childId);
        //on exiting from above function folder should be empty so it can be deleted without problem
                deleteEmptyFolder(id);
            } else {
                deleteitem(id);
            }
    //it should be while loop and we have to find another child inside the loop
            childId = findNextChildId(id)
          }
        }
    
    findNextChildId(int parentId){
       Coursor yourCoursor;
      while(yourCoursor.moveToNext()){
        if (parentId==yourCoursor.getInt("PARENT")){
            yourCoursor.getInt("ID");
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using SQLite from .net, Is there a way to access the .dump command or
I have created tables in android sqlite using create statement and also inserted values
I am learning sqlite using the example from sqldf , I have come across
Can SQLite sort naturally? For example, CREATE TABLE animals ( id INTEGER NOT NULL
I store some time values in sqlite in %H:%M string format (for example 15:43),
Using SQLite I need to copy nearly all of an existing row from a
Good night, I have an SQLite query which I am executing in C# using
I'm looking for some information regarding using SQLITE with AIR in Flash CS4, I
Possible Duplicate: sqlite example program in android I need to open a database where
I currently successfully use a SQLite database which is populated with data from the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.