java.util.ArrayList.size()' on a null object reference
<p>I want to pull data from my Firebase database. My table name is "cardornek". And I set the permissions for read/write. </p>

<p>But I get this "java.util.ArrayList.size()' on a null object reference" error. Any idea?</p>

<p><strong>RecyclerViewAdapter.java</strong></p>

<pre><code>public class RecyclerViewAdapter extends RecyclerView.Adapter&lt;RecyclerViewAdapter.ViewHolder&gt; {

private ArrayList&lt;String&gt; values=null;
RecyclerViewAdapter(ArrayList&lt;String&gt; values) {
    this.values = values;
}
@Override
public RecyclerViewAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    return new ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.recycler_view_item,parent,false));
}


@Override
public void onBindViewHolder(RecyclerViewAdapter.ViewHolder holder, int position)
{
    holder.name.setText(values.get(position));
}

@Override
public int getItemCount() {
    return values.size();
}

public class ViewHolder extends RecyclerView.ViewHolder
{
    private TextView name;
    ViewHolder(View itemView) {
        super(itemView);
        name = (TextView) itemView.findViewById(R.id.list_item_text);
    }
}
</code></pre>

<p><strong>MainActivity.java</strong></p>

<pre><code>public class MainActivity extends AppCompatActivity {
private RecyclerView recyclerView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    new GetDataFromFirebase().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

    // Read from the database
    FirebaseDatabase database = FirebaseDatabase.getInstance();
    DatabaseReference myRef = database.getReference("cardornek");

    myRef.addValueEventListener(new ValueEventListener() {


        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            ArrayList&lt;String&gt; values = (ArrayList&lt;String&gt;) dataSnapshot.getValue();
            recyclerView.setAdapter(new RecyclerViewAdapter(values));
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {
            System.out.println("Failed to read value." + databaseError.toException());
        }
    });
</code></pre>