title: firebase recycler view crashing on scrolling down
body: <p>Hii I am trying to read data from firebase database and storage to Firebase recycler everything is working fine till I am scrolling the Recycler view down then app is crashing here is my code</p>
  
  <p>MODEL CLASS</p>
  
  <pre><code> package com.example.ace.park;
  
  public class model {
      public String name,num,type,sno;
  
  
      public model(String name, String num, String type, String sno) {
          this.name = name;
          this.num = num;
          this.type = type;
          this.sno = sno;
      }
  
      public model() {
      }
  }
  </code></pre>
  
  <p>Here is JAVA CLASS</p>
  
  <pre><code>package com.example.ace.park;
  
  import android.content.Intent;
  import android.support.annotation.NonNull;
  import android.support.design.widget.NavigationView;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.support.v7.widget.LinearLayoutManager;
  import android.support.v7.widget.RecyclerView;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.TextView;
  import android.widget.Toast;
  
  import com.firebase.ui.database.FirebaseRecyclerAdapter;
  import com.firebase.ui.database.FirebaseRecyclerOptions;
  import com.google.firebase.database.DatabaseReference;
  import com.google.firebase.database.FirebaseDatabase;
  
  public class dis extends AppCompatActivity {
  
  
      NavigationView navigationView;
      TextView textView;
      Intent intent;
      FirebaseRecyclerAdapter&lt;model, displayAdapter&gt; adapter;
      FirebaseRecyclerOptions&lt;model&gt; options;
      RecyclerView recyclerView;
      DatabaseReference mDatabase,query;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_dis);
  
          recyclerView = findViewById(R.id.myRecView);
  
  
          mDatabase = FirebaseDatabase.getInstance().getReference().child("parkings");
          recyclerView.setHasFixedSize(true);
          recyclerView.setLayoutManager(new LinearLayoutManager(this));
  
          query = FirebaseDatabase.getInstance().getReference().child("parkings");
  
          options = new FirebaseRecyclerOptions.Builder&lt;model&gt;()
                  .setQuery(query, model.class)
                  .build();
  
          adapter = new FirebaseRecyclerAdapter&lt;model, displayAdapter&gt;(
                  options) {
              @Override
              public displayAdapter onCreateViewHolder(ViewGroup parent, int viewType) {
                  View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.recycler, parent, false);
  
  
                  return new displayAdapter(v);
              }
  
              @Override
              protected void onBindViewHolder(displayAdapter holder, final int position, final model current) {
  
                  holder.setName(current.name);
                  holder.setTotal(current.num);
                  holder.setType(current.type);
                  holder.setImage(getApplicationContext(),current.sno,current.sno);
  
                  holder.mview.setOnClickListener(new View.OnClickListener() {
                      @Override
                      public void onClick(View v) {
                          Toast.makeText(dis.this, ""+position, Toast.LENGTH_SHORT).show();
  
  
                      }
                  });
              }
  
  
          };
  
          //Populate Item into Adapter
          recyclerView.setAdapter(adapter);
  
  
  
      }
  
      @Override
      protected void onStart() {
          super.onStart();
          adapter.startListening();
  
  
  
      }
  
      @Override
      protected void onStop() {
          super.onStop();
          adapter.stopListening();
      }
  
  }
  </code></pre>
  
  <p>Here is Adapter</p>
  
  <pre><code>package com.example.ace.park;
  
  import android.content.Context;
  import android.graphics.Bitmap;
  import android.graphics.BitmapFactory;
  import android.support.annotation.NonNull;
  import android.support.v7.widget.RecyclerView;
  import android.view.View;
  import android.widget.ImageView;
  import android.widget.TextView;
  import android.widget.Toast;
  
  import com.google.android.gms.tasks.OnFailureListener;
  import com.google.android.gms.tasks.OnSuccessListener;
  import com.google.firebase.storage.FileDownloadTask;
  import com.google.firebase.storage.FirebaseStorage;
  import com.google.firebase.storage.StorageReference;
  
  import java.io.File;
  import java.io.IOException;
  
  public class displayAdapter extends RecyclerView.ViewHolder {
  
      public View mview;
      public displayAdapter(View itemView) {
          super(itemView);
          mview = itemView;
  
      }
      public void setName(String name){
          TextView recName = mview.findViewById(R.id.recyclerName);
          recName.setText(name);
      }
      public void setTotal(String title){
          TextView t = mview.findViewById(R.id.recyclerTotal);
          t.setText(title);
      }
      public void setType(String type){
          TextView t = mview.findViewById(R.id.recyclerType);
          t.setText(type);
      }
      public void setImage(Context ctx, String image,String user){
          final ImageView iv = mview.findViewById(R.id.recyclerImg);
  
          FirebaseStorage storage = FirebaseStorage.getInstance();
          StorageReference storageReference = storage.getReference().child("Parkings"+"/"+image);
          try {
              final File localFile = File.createTempFile("images", "jpg");
              storageReference.getFile(localFile).addOnSuccessListener(new OnSuccessListener&lt;FileDownloadTask.TaskSnapshot&gt;() {
                  @Override
                  public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) {
                      Bitmap bitmap = BitmapFactory.decodeFile(localFile.getAbsolutePath());
                      iv.setImageBitmap(bitmap);
  
                  }
              }).addOnFailureListener(new OnFailureListener() {
                  @Override
                  public void onFailure(@NonNull Exception exception) {
                  }
              });
          } catch (IOException e ) {
              Toast.makeText(ctx, "Error in Adapter", Toast.LENGTH_SHORT).show();
  
  
  
          }
  
      }
  
  }
  </code></pre>
  
  <p>This is recycler layout</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.v7.widget.CardView
  
      xmlns:android="http://schemas.android.com/apk/res/android"
  
      android:layout_width="match_parent"
  
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:orientation="vertical"
      app:cardCornerRadius="10dp"
      android:layout_height="wrap_content"&gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:orientation="vertical"
  
          &gt;
          &lt;TextView
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:id="@+id/recyclerName"
              android:paddingLeft="20dp"
              android:paddingRight="20dp"
              android:textColor="#212020"
              android:textSize="30sp"
              android:text="@string/name_of_place"
              /&gt;
  
          &lt;ImageView
              android:layout_width="300dp"
              android:layout_marginTop="30dp"
              android:layout_height="230dp"
              android:scaleType="centerCrop"
              android:paddingLeft="10dp"
              android:layout_gravity="center"
              android:paddingRight="10dp"
              android:id="@+id/recyclerImg"
              android:contentDescription="@string/img"
              /&gt;
  
  
          &lt;TextView
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:paddingLeft="15dp"
              android:paddingRight="15dp"
              android:textColor="#615f5f"
              android:textSize="18sp"
              android:id="@+id/recyclerTotal"
              android:text="@string/tsp"
              /&gt;
  
          &lt;TextView
              android:layout_width="match_parent"
              android:layout_marginTop="5dp"
              android:text="@string/type"
              android:paddingLeft="15dp"
              android:paddingRight="15dp"
              android:id="@+id/recyclerType"
              android:layout_height="25dp"
              android:textSize="18sp"
              android:layout_marginBottom="5dp"
              /&gt;
      &lt;/LinearLayout&gt;
  
  
  &lt;/android.support.v7.widget.CardView&gt;
  </code></pre>
  
  <p>Logcat is giving his error</p>
  
  <p>11-21 20:37:32.885 9681-9681/com.example.ace.park E/AndroidRuntime: FATAL EXCEPTION: main
      Process: com.example.ace.park, PID: 9681
      com.google.firebase.database.DatabaseException: Can't convert object of type java.lang.Long to type com.example.ace.park.model
          at com.google.firebase.database.core.utilities.encoding.CustomClassMapper.convertBean(com.google.firebase:firebase-database@@16.0.5:423)
          at com.google.firebase.database.core.utilities.encoding.CustomClassMapper.deserializeToClass(com.google.firebase:firebase-database@@16.0.5:214)
          at com.google.firebase.database.core.utilities.encoding.CustomClassMapper.convertToCustomClass(com.google.firebase:firebase-database@@16.0.5:79)
          at com.google.firebase.database.DataSnapshot.getValue(com.google.firebase:firebase-database@@16.0.5:212)
          at com.firebase.ui.database.ClassSnapshotParser.parseSnapshot(ClassSnapshotParser.java:29)
          at com.firebase.ui.database.ClassSnapshotParser.parseSnapshot(ClassSnapshotParser.java:15)
          at com.firebase.ui.common.BaseCachingSnapshotParser.parseSnapshot(BaseCachingSnapshotParser.java:35)
          at com.firebase.ui.common.BaseObservableSnapshotArray.get(BaseObservableSnapshotArray.java:52)
          at com.firebase.ui.database.FirebaseRecyclerAdapter.getItem(FirebaseRecyclerAdapter.java:106)
          at com.firebase.ui.database.FirebaseRecyclerAdapter.onBindViewHolder(FirebaseRecyclerAdapter.java:122)
          at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6673)
          at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6714)
          at android.support.v7.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5647)
          at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5913)
          at android.support.v7.widget.GapWorker.prefetchPositionWithDeadline(GapWorker.java:285)
          at android.support.v7.widget.GapWorker.flushTaskWithDeadline(GapWorker.java:342)
          at android.support.v7.widget.GapWorker.flushTasksWithDeadline(GapWorker.java:358)
          at android.support.v7.widget.GapWorker.prefetch(GapWorker.java:365)
          at android.support.v7.widget.GapWorker.run(GapWorker.java:396)
          at android.os.Handler.handleCallback(Handler.java:789)
          at android.os.Handler.dispatchMessage(Handler.java:98)
          at android.os.Looper.loop(Looper.java:164)
          at android.app.ActivityThread.main(ActivityThread.java:6541)
          at java.lang.reflect.Method.invoke(Native Method)
          at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)</p>
  
  <p><a href="https://i.stack.imgur.com/V9o7v.png" rel="nofollow noreferrer">this is image of database structure</a></p>