title: Store an Object that has a List<Object> and a string, inside a SQLiteDatabase
body: <p>First of all, sorry for the very strange question title, I couldn't figure out a better way to word it!</p>
  
  <p>So I have an Object as follows, it has a String for the name of the exercise (saves duplication inside the List), and the List of Set Objects, each set has a weight(double) and a number of reps(int).  </p>
  
  <pre><code>public class Card implements Serializable {
  public String name;
  List&lt;Set&gt; sets;
  
  public Card(String name) {
      this.name = name;
      sets = new ArrayList&lt;&gt;();
  }
  
  public String getName() {
      return name;
  }
  
  public List&lt;Set&gt; getSet() {
      return sets;
  }
  
  public void addSet(Set s) {
      sets.add(s);
  }
  
  public String toString(){
      return "Name: " + name + ", Set: " + sets.toString();
  }}
  </code></pre>
  
  <p>Now I want to store this inside of a database. How would I go about achieving this, because I know I cant store a List inside a database unless I give it its own table, but each member of the list has a name which is the String name, and this name would come up multiple times in the database, so it isnt unique to just this set of sets (sorry about the wording!! :P ) 
  Hopefully one of you can decipher my poorly worded question and explanation and provide me with an answer :)
  need anymore info, just leave a comment!</p>
  
  <p>EDIT: I have it all sussed but I now have a new issue, my foreign key isnt autoincrementing like my primary key, my code for my tables is as follows</p>
  
  <pre><code>public static final String CREATE_CARD_TABLE = "CREATE TABLE "
          + CARD_TABLE + "(" + CARD_ID
          + " INTEGER PRIMARY KEY AUTOINCREMENT, " + CARD_NAME
          + " TEXT )";
  
  //card foreign key, this will be where the card information is stored.
  public static final String CREATE_CARDINFO_TABLE = "CREATE TABLE "
          + CARD_INFO_TABLE + "(" + CARD_ID2
          + " INTEGER, " + CARD_NAME2
          + " TEXT, " + CARD_WEIGHT
          + " REAL, " + CARD_REPS
          + " INTEGER, "
          + " FOREIGN KEY " + "("+ CARD_ID2 +")"+ " REFERENCES " + CARD_TABLE + "("+CARD_ID+"));";
  </code></pre>
  
  <p>and then I insert data to them as follows, where am I going wrong?? </p>
  
  <pre><code>    public void insertEntry(String name, double weight, int reps) {
      open();
      database.beginTransaction();
      if(flag == 0) {
          ContentValues newValues = new ContentValues();
          // Assign values for each row.
          newValues.put(DataBaseHelper.CARD_NAME, name);
  
          // Insert the row into your table
          database.insert(DataBaseHelper.CARD_TABLE, null, newValues);
          flag = 1;
      }
  
      ContentValues newValues = new ContentValues();
      // Assign values for each row.
      newValues.put(DataBaseHelper.CARD_NAME2, name);
      newValues.put(DataBaseHelper.CARD_WEIGHT, weight);
      newValues.put(DataBaseHelper.CARD_REPS, reps);
  
      // Insert the row into your table
      database.insert(DataBaseHelper.CARD_INFO_TABLE, null, newValues);
      database.setTransactionSuccessful();
      database.endTransaction();
      close(); 
  }
  </code></pre>