Insert ArrayList in SQLite Database
<p>I have an ArrayList coming from an API and my POJO (Plain Old Java Object) has the required getters and setters required.</p>

<pre><code>@SerializedName("staff")
@Expose
private List&lt;String&gt; staff = new ArrayList&lt;String&gt;();
@SerializedName("departments")
@Expose
private List&lt;String&gt; departments = new ArrayList&lt;String&gt;();
</code></pre>

<p>I want to ad the staff and department into an <strong>SQLite Table</strong>.
My existing table has the rest of the strings values. But i am not able to add the <strong>ArrayList</strong> into the table.</p>

<pre><code>public static final String CREATE_TABLE_QUERY = "CREATE TABLE " + TABLE_NAME + "" +
            " (" + ID + " TEXT PRIMARY KEY not null, " +
            //need to change product id into String or TEXT
            CLIENTS_NAME + " TEXT not null," +
            CLIENTS_ADDRESS1 + " TEXT not null," +
            CLIENTS_ADDRESS2 + " TEXT not null," +
            CLIENTS_ADDRESS3 + " TEXT not null," +
            CLIENTS_ADDRESS4 + " TEXT not null," +
            TYPE + " TEXT not null," +
            CLIENTS_CONTACT + " TEXT not null)" ;
</code></pre>

<p>How do i add the Arraylist ?
I have tried <a href="https://stackoverflow.com/questions/5703330/saving-arraylists-in-sqlite-databases">this</a> but its not working.
Any Links or Hints will be appreciated.</p>

<p>This is the insertion of the rest of the string values into the database.Note, i have still not added the <strong>staff</strong> into the database table yet as i dont know how to insert a Arraylist in the table.</p>

<pre><code> public void addProducts(Clients_POJO products) {
    //CRUD , adding Products

    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues values = new ContentValues();
    values.put(Constants.ClientsDATABASE.ID, products.getId());
    values.put(Constants.ClientsDATABASE.CLIENTS_NAME, products.getName());
    values.put(Constants.ClientsDATABASE.CLIENTS_ADDRESS1, products.getAddress1());
    values.put(Constants.ClientsDATABASE.CLIENTS_ADDRESS2, products.getAddress2());
    values.put(Constants.ClientsDATABASE.CLIENTS_ADDRESS3, products.getAddress3());
    values.put(Constants.ClientsDATABASE.CLIENTS_ADDRESS4, products.getAddress4());
    values.put(Constants.ClientsDATABASE.TYPE, products.getType());
    values.put(Constants.ClientsDATABASE.CLIENTS_CONTACT, products.getContact());

    try {

        db.insert(Constants.ClientsDATABASE.TABLE_NAME, null, values);
    } catch (Exception e) {
        Log.d(TAG, e.getMessage());
    }
</code></pre>