title: Saving Multiple Arraylist in Room Database - Best way of doing it?
body: <p><strong>Background:</strong>
  I am trying to build a Deckbuilder for a Cardgame. The different decks are based on 
  one Arraylists that I want to safe locally. That means you can create your deck and than I want you to be able to safe it, and then create a new deck, be able to save it again... <em>-> This yields multiple Arraylists that I want to safe in the same class.</em></p>
  
  <p><strong>Question:</strong>
  What is the best way of storing the Arraylists in Room while knowing that I want to there is not only one Arraylist coming?</p>
  
  <p>From what I know now is that I have to create a entity class which would basically create me one(?) table, where I would have to save the Arraylists after each other?</p>
  
  <p>Is there a better way of doing it.</p>
  
  <p><strong>Bonus:</strong>
  I would love an basic example of how to do it aswell, since this seems like a super hard to achieve by myself.</p>
  
  <p>Thanks very much!</p>
  
  <p>Edit:</p>
  
  <p><strong>Code Sample</strong></p>
  
  <p>So what I implemented with the baseline from your codesample is the following:</p>
  
  <ol>
  <li><p>I created the class SaveDeck which should be able to <em>Save a Deck with a given Deckname</em>:
  :-</p>
  
  <p>@Entity
  public class SaveDeck implements Serializable {
      @PrimaryKey(autoGenerate = true)
      private int _id;</p>
  
  <pre><code>public SaveDeck(int _id, String deckName, int cardImage, int typeImage, Integer cardCost, String cardName, Integer cardNumber) {
      this._id = _id;
      DeckName = deckName;
      CardImage = cardImage;
      TypeImage = typeImage;
      CardCost = cardCost;
      CardName = cardName;
      CardNumber = cardNumber;
  }
  
  @ColumnInfo(name = "DeckName")
  private String DeckName;
  
  @ColumnInfo(name = "CardImage")
  private int CardImage;
  
  @ColumnInfo(name = "TypeImage")
  private int TypeImage;
  
  @ColumnInfo(name = "CardCost")
  private Integer CardCost;
  
  @ColumnInfo(name = "CardName")
  private String CardName;
  
  @ColumnInfo(name = "CardNumber")
  private Integer CardNumber;
  </code></pre>
  
  <p>}</p></li>
  <li><p>I created the Dao Class as follows:
  :-</p>
  
  <p>@Dao
  public interface DeckBuilderDao {</p>
  
  <pre><code>@Insert(onConflict = OnConflictStrategy.IGNORE)
  public long[] insertCards(SaveDeck... saveDecks);
  
  @Insert(onConflict = OnConflictStrategy.IGNORE)
  public long insertCard(SaveDeck saveDecks);
  
  @Update
  public int updateCardBaseEntries(SaveDeck... saveDecks);
  
  @Update
  public int updateCardBaseEntry(SaveDeck saveDecks);
  
  @Delete
  public int deleteCardBaseEntried(SaveDeck... saveDecks);
  
  @Delete
  public int deleteCardBaseEntry(SaveDeck saveDecks);
  
  @Query("SELECT * FROM SaveDeck")
  public SaveDeck[] getAllDecks();
  
  //probably I do not need the getAllDecks Query. Right now I only need the following one:
  @Query("SELECT * FROM SaveDeck WHERE DeckName = :NameOfDeck ORDER  BY DeckName, CardName")
  public SaveDeck getOneDeck(String NameOfDeck);
  </code></pre>
  
  <p>}</p></li>
  <li><p>Furthermore created the DataBase Class:</p>
  
  <p>@Database(entities = {SaveDeck.class}, version = 1)
  public abstract class SaveDecksDataBase extends RoomDatabase {
      public abstract DeckBuilderDao deckBuilderDao();
  }</p></li>
  <li><p>Finally tried to create the setup in my respective fragment, this is where I struggle:
  :-</p>
  
  <p>public class review_fragment extends Fragment {</p>
  
  <pre><code>private List&lt;TransferDeck&gt; mTransferDeck = DataHolder.getInstance().savedDecklistTransfer;
  SaveDecksDataBase mSavedDecksDB;
  Cursor mCursor;
  
  public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
  //return super.onCreateView(inflater, container, savedInstanceState);
      View view = inflater.inflate(R.layout.review_fragment, container, false);
  
      /*Introduce Cards Recycler*/
  
      RecyclerView rvCards = view.findViewById(R.id.rv_review_cardlist);
      rvCards.setLayoutManager(new GridLayoutManager(getActivity(), 5));
      review_RViewAdapter_Cards adapterCards = new review_RViewAdapter_Cards(getContext(), mTransferDeck);
      rvCards.setAdapter(adapterCards);
  
  
  
      /*Init Room database*/
      mSavedDecksDB = Room.databaseBuilder(getActivity(),SaveDecksDataBase.class,"SavedDecksDB.db").build();
      populateDB(mTransferDeck);
  
  
  
  
  
      return view;
  }
  
  private void populateDB(final List&lt;TransferDeck&gt; mTransferDeck) {
      new Thread(new Runnable() {
          @Override
          public void run() {
              List&lt;SaveDeck&gt; mSaveDeck = new ArrayList&lt;&gt;();
              for(int i = 0; i&lt;mTransferDeck.size(); i++){
                  mSaveDeck.add(new SaveDeck(i, "FirstSavedDeck", mTransferDeck.get(i).getCardImage() ,mTransferDeck.get(i).getTypeImage(), mTransferDeck.get(i).getCost(), mTransferDeck.get(i).getName(), mTransferDeck.get(i).getNumber()));
              }
              mSavedDecksDB.deckBuilderDao().insertCards(mSaveDeck);
  
          }
      }).start();
  }
  </code></pre>
  
  <p>}</p></li>
  </ol>
  
  <p><strong>So right now I do not know how to correctly add new instances to my Class <code>SaveDeck</code>. I am used to use Arraylists, with constructors.</strong> Therefore I tried it that way. Could you maybe have a look on it and give me a helping hand please?</p>