title: How to store and retrieve array [ ] objects using Room in Android?
body: <p>I have seen tons of example saving and retrieving ArrayList in Room, Android. But I can't find how to store the classical array [] objects as a field in Room. When I use a type Converter I get the errors: </p>
  
  <p><strong>"Error:(55, 18) error: Not sure how to convert a Cursor to this method's return type"</strong>
  <strong>"Error:(61, 38) error: Query method parameters should either be a type that can be converted into a database column or a List / Array that contains such type. You can consider adding a Type Adapter for this."</strong></p>
  
  <p>Here is the code:</p>
  
  <p>Database file:</p>
  
  <pre><code>@Database(entities = {UserModel.class}, version = 4)
  @TypeConverters({TutorsModelArrayConverter.class})
  public abstract class AppDatabase extends RoomDatabase {
     .... Database methods
  }
  </code></pre>
  
  <p>Model File:</p>
  
  <pre><code>@Entity(primaryKeys = {"user_id"})
  public class UserModel {
      private String user_id;  
      private TutorModel[] tutors;
      .... Other parameters
  </code></pre>
  
  <p>}  </p>
  
  <p>Converter file:</p>
  
  <pre><code>public class TutorsModelArrayConverter {
  
  @TypeConverter
  public static TutorModel[] toListTutor(String tutorModel) {
      if (tutorModel == null) {
          return null;
      }
      Gson gson = new Gson();
      Type type = new TypeToken&lt;TutorModel[]&gt;() {}.getType();
      return gson.fromJson(tutorModel, type);
  }
  
  @TypeConverter
  public static String tutorModelToString(TutorModel[] tutorModels) {
      if (tutorModels != null) {
          return new Gson().toJson(tutorModels);
      }else
          return null;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>DAO file:</p>
  
  <pre><code>@Dao
  public interface DAO_DBHelper {
  
      @Query("SELECT tutors FROM AppData WHERE fake_id = 1")
      TutorModel[] getTutorList();
  
      ... Other methods
  }
  </code></pre>
  
  <p>My question is how can I store an array [] of objects in Room and get around the Errors before mentioned. Any clue is welcome! Thanks in advance!</p>