Android Question Parent/Child Example

aklisiewicz

Active Member
Licensed User
Longtime User
I found one example project for SQLite with the parent/child structure but it is not what I need - it is just to straightfoward. Is there any more complex Parent/Child relationship example App ?
I'm looking for something like Invoice example.

I need to create an App with following features
1
Main table listing records. The main (Parent table) will have about 12 Child tables.
I would like to be able to place either buttons (at the bottom of the screen) or Tabs, where each button or tab will represent (display) another list of Child records.

2.
On LongPress I want to display a form with the parent record and beneath Tabs or Buttons allowinh to display Child records, then upon LongPress each Child record would open and display its details on the form.

QUESTION: I'm beginer...
which would be easier to implement (local SQLite dB) ?
 

aklisiewicz

Active Member
Licensed User
Longtime User
Parent/Child (or sometimes Master/Detail) is a common term. If you look at INVOICE it is based on this relation, where the Invoice_Header has Invoice_Items records. Of course in SQL this is all done by JOINS. I was wondering is there is an INVOICE example anywhere available ?
Thanks - Arthur
 
Upvote 0

devlei

Active Member
Licensed User
Longtime User
The common way is to use 'joins' as has been mentioned above, especially if you come from a RDBMS background such as MS Access. Because SQLite is so simple and powerful, I have found it easier just to include a LinkID field when creating the Table.

Then you can have any number of levels (parent/child or master/detail) on your activity. I often use 3 levels - the top one being a Spinner, the 2nd and 3rd being Listviews. Selecting a top level displays the 'child' records (in summarised form) in the 2nd level (ListView); and selecting a 2nd level item will display the 'child' records in the 3rd level (ListView).

Obviously, when populating any level, you need to store the ItemID so that you can quickly access the 'child' records via the LinkID. For ListViews use ListView.AddSingleItem2 for this purpose.
 
Upvote 0

Itila Tumer

Active Member
Licensed User
Longtime User
Are there any example db or example project? two DB are relation between them. I want to connect kilos,tall with names forexample. How could I do that ???
 
Upvote 0

Itila Tumer

Active Member
Licensed User
Longtime User
Hi
I looked at DBUtils example. but I couln't understand enough. I couldnt see any JOIN part.

and it makes random db , it made me confused also. I 'd like to use real .db . I think I'd like to do the same like " aklisiewicz "
 
Upvote 0

Itila Tumer

Active Member
Licensed User
Longtime User
Thanks you so much. I think it will resque me. Do you think this is much better than other ( with Join) ?
And I had an idea. can I display in different TabHost page if I want to ??
 
Upvote 0

Itila Tumer

Active Member
Licensed User
Longtime User
Dear LucaMs,

Could I try to make 3 tables and , can we reach from first table to last one ? Is that possible?? How could I do that If it 's possible.

Another question is why we use REGİONs like that? what is the difference? It works without Regions too.
 
Last edited:
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
I use many Regions to split code to see only what I need (I often use ALT + E, o, c, try).

You can Join how many tables you want and you can extract fields from each table.
Try to use some query builder tool (if you do not find free tools for SQLite, you can do some tests using MS Access)
 
Upvote 0
Top