Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Generally (from what I have learned) if you have an object, which itself contains a list of other objects, that would be a 1 to many (or potentially many-to-many) relationship. To store this data you would want to use another table. In the other table, you will have your primary key for the object, and then a foreign key referencing the parent object to which it belongs. See <a href="http://en.wikipedia.org/wiki/Foreign_key" rel="noreferrer">this</a> link for a better explanation.</p> <p>Example:</p> <pre><code>CREATE TABLE User ( _id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, name TEXT ); CREATE TABLE UserPicture( _id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, userId INTEGER, path TEXT FOREIGN KEY(userId) REFERENCES User(_id) ); </code></pre> <p>Now say you have a user object, with a List of UserPictures', when you save to the database you will want to iterate over each picture and insert each one into the UserPicture table, using the userId as the link back to the User table. </p> <p>In the instance of a many-to-many relationship, each Object would have a List of their children objects. A better example of this would be a Membership/Role system. A User would have a List of Roles, and a Role would have a List of Users, since a user can (normally) be in multiple roles, and a role can of course have multiple users. This would simply require whats called a join table I think it is. UserInRole would have two columns, UserID and RoleID to show that User X belongs to Role Y.</p> <p>As far as how to implement it, search around for 'Android sqlite tutorial'. <a href="http://developer.android.com/resources/tutorials/notepad/index.html" rel="noreferrer">Here</a> and <a href="http://www.vogella.de/articles/AndroidSQLite/article.html" rel="noreferrer">here</a> are two links with tutorials on how to setup a sqlite android database app.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload