title: Defining Constructors in Model Class (Get Data with Cloud Firestore)
body: <p>I added some data in <strong>Cloud Firestore</strong> <a href="https://i.stack.imgur.com/lB6QA.png" rel="nofollow noreferrer">enter image description here</a></p>
  
  <p>in which I am having String title, String desc, String[] photos</p>
  
  <p>I want to get that data in <strong>MyClass.class</strong> so I provided <strong>Parameterized Constructor</strong> and <strong>Getter &amp; Setters</strong> in the class.</p>
  
  <p>But the error said <strong>Converting to Arrays is not supported, please use Lists instead</strong></p>
  
  <p>This is my code for logical part:</p>
  
  <pre><code>FirebaseFirestore db = FirebaseFirestore.getInstance();
  
          db.collection("gallery")
                  .get()
                  .addOnCompleteListener(new OnCompleteListener&lt;QuerySnapshot&gt;() {
                      @Override
                      public void onComplete(@NonNull Task&lt;QuerySnapshot&gt; task) {
                          if (task.isSuccessful()) {
                              for (QueryDocumentSnapshot document : task.getResult()) {
                                  Log.d("MyTag", document.getId() + " =&gt; " + document.getData());
                                  MyClass obj = document.toObject(MyClass.class);
                              }
                          } else {
                              Log.d("Main", "Error getting documents: ", task.getException());
                          }
                      }
                  });
  </code></pre>
  
  <p>This is my Class: </p>
  
  <pre><code>public class MyClass {
  
      String title;
      String desc;
      String[] photos;
  
      public MyClass(){}
  
      public MyClass(String title, String desc, String[] photos) {
          this.title = title;
          this.desc = desc;
          this.photos = photos;
      }
  
      public String getTitle() {
          return title;
      }
  
      public void setTitle(String title) {
          this.title = title;
      }
  
      public String getDesc() {
          return desc;
      }
  
      public void setDesc(String desc) {
          this.desc = desc;
      }
  
      public String[] getPhotos() {
          return photos;
      }
  
      public void setPhotos(String[] photos) {
          this.photos = photos;
      }
  </code></pre>
  
  <p>And I am getting this error at MyClass obj = document.toObject(MyClass.class)
   :</p>
  
  <pre><code>FATAL EXCEPTION: main
                    Process: com.developtrainmaintain.firebaserecycle, PID: 3836
                    java.lang.RuntimeException: Could not deserialize object. Converting to Arrays is not supported, please use Lists instead (found in field 'photos')
                        at com.google.android.gms.internal.firebase-firestore.zzko.zzb(Unknown Source)
                        at com.google.android.gms.internal.firebase-firestore.zzko.zza(Unknown Source)
                        at com.google.android.gms.internal.firebase-firestore.zzko.zza(Unknown Source)
                        at com.google.android.gms.internal.firebase-firestore.zzko.zzb(Unknown Source)
                        at com.google.android.gms.internal.firebase-firestore.zzko$zza.zza(Unknown Source)
                        at com.google.android.gms.internal.firebase-firestore.zzko.zza(Unknown Source)
                        at com.google.android.gms.internal.firebase-firestore.zzko.zza(Unknown Source)
                        at com.google.firebase.firestore.DocumentSnapshot.zza(Unknown Source)
                        at com.google.firebase.firestore.QueryDocumentSnapshot.zza(Unknown Source)
                        at com.google.firebase.firestore.DocumentSnapshot.toObject(Unknown Source)
                        at com.google.firebase.firestore.QueryDocumentSnapshot.toObject(Unknown Source)
                        at com.developtrainmaintain.firebaserecycle.MainActivity$1.onComplete(MainActivity.java:48)
                        at com.google.android.gms.tasks.zzj.run(Unknown Source)
                        at android.os.Handler.handleCallback(Handler.java:733)
                        at android.os.Handler.dispatchMessage(Handler.java:95)
                        at android.os.Looper.loop(Looper.java:136)
                        at android.app.ActivityThread.main(ActivityThread.java:5017)
                        at java.lang.reflect.Method.invokeNative(Native Method)
                        at java.lang.reflect.Method.invoke(Method.java:515)
                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
                        at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p><strong>Please help me with this problem :(</strong></p>