title: Issues with Android Studio Room Type Converter
body: <p>For some reason, I am having issues with the typeconverter in Android Studios. I have tried a variety of solutions from other posts, but continue to get this error. When I tried Arraylist of strings, instead of ingredients, the typeconverter does work.</p>
  
  <p><code>error: Cannot figure out how to save this field into database. You can consider adding a type converter for it.</code></p>
  
  <pre><code>@Entity(tableName = "Recipes")
      public class recipesDB {
          @PrimaryKey
          @NonNull
          @ColumnInfo(name = "recipeID")
          private int id;
  
      //Foreign Key to be used from Ingredients
      @ColumnInfo(name = "name")
      private String name;
  
      @ColumnInfo(name = "url")
      private String url;
  
      @ColumnInfo(name = "readyInMinutes")
      private int readyInMinutes;
  
  //Issue Here
  @ColumnInfo(name = "ingredients")
  private ArrayList&lt;ingredient&gt; ingredients;
  </code></pre>
  
  <p>DataConverter class:</p>
  
  <pre><code>public class DataConverter{
  
  
      @TypeConverter
      public static ArrayList&lt;ingredient&gt; toIngredient(String s){
          if(s == null){
              return null;
          }
  
          Gson gson = new Gson();
          Type listType = new TypeToken&lt;ArrayList&lt;ingredient&gt;&gt;(){}.getType();
          ArrayList&lt;ingredient&gt; ingredients = gson.fromJson(s, listType);
          return ingredients;
      }
  
      @TypeConverter
      public static String getIngredients(ArrayList&lt;ingredient&gt; ingredients){
          if(ingredients == null){
              return null;
          }
  
          Gson gson = new Gson();
          Type type = new TypeToken&lt;ArrayList&lt;ingredient&gt;&gt;() {}.getType();
          String json = gson.toJson(ingredients);
          return json;
      }
  </code></pre>
  
  <p><strong>EDIT</strong>
  AppDatabase:</p>
  
  <pre><code>@Database(entities = {recipesDB.class}, version = 1, exportSchema = false)
  @TypeConverters({DataConverter.class})
  public abstract class AppDatabase extends RoomDatabase {
      private static AppDatabase INSTANCE;
      public abstract recipesDAO recipesdao();
      //public abstract pantryDAO pantrydao();
      public static AppDatabase getInMemoryDatabase(Context context) {
          if (INSTANCE == null) {
              INSTANCE = Room.inMemoryDatabaseBuilder(context.getApplicationContext(), AppDatabase.class).build();
          }
          return INSTANCE;
      }
      public static void destroyInstance(){INSTANCE = null;}
  }
  </code></pre>