Q:

How to fix null pointer from firebase when getting a key?

I got an error, for not getting data from firebase, I don't know why but I try to set the key to my modeldata. And when I try to put it on Recycleview. I got an error when I tried to get the data. 
Take a look at my code.
ListActivity
public class ListActivity extends BaseActivity {

    private DatabaseReference databaseReference;
    private RecyclerView labelRecycleView;
    private ArrayList<DataFirebase> listLabel;
    private listAdapter listAdapter;
    private Button bInput;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_list);
        findView();
        setDataToList();
        initListener();
        putLayoutManager();
    }

    private void setDataToList() {
        simpleway.progressDialog(ListActivity.this);
        databaseReference.child("Username").addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
                listLabel = new ArrayList<>();
                for (DataSnapshot dataSnap : dataSnapshot.getChildren()) {

                    DataFirebase modelClass = dataSnap.getValue(DataFirebase.class);
                    modelClass.setLabel(dataSnap.getKey());
                    listLabel.add(modelClass);
                }
                listAdapter = new listAdapter(listLabel, ListActivity.this);
                labelRecycleView.setAdapter(listAdapter);
                simpleway.stopProgressDialog();
            }

            @Override
            public void onCancelled(@NonNull DatabaseError databaseError) {
                System.out.println(databaseError.getDetails() + " " + databaseError.getMessage());
                simpleway.stopProgressDialog();
            }
        });
    }

    private void putLayoutManager() {
        RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getApplicationContext());
        labelRecycleView.setLayoutManager(layoutManager);
        labelRecycleView.setItemAnimator(new DefaultItemAnimator());
    }

    @Override
    public void findView() {
        databaseReference = FirebaseDatabase.getInstance().getReference();
        labelRecycleView = findViewById(R.id.listRecyclerVIew);
        bInput = findViewById(R.id.inputData);
    }

    @Override
    public void initListener() {
        bInput.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                simpleway.startnextActivity(ListActivity.this, InputActivity.class);
            }
        });
    }

    }

and this is my adapter it show that i cant get data from my label.
ListAdapter
public class listAdapter extends RecyclerView.Adapter<listAdapter.ViewHolder> {

    private List<DataFirebase> dataList;
    private AppCompatActivity someActivity;

    public listAdapter(List<DataFirebase> dataFirebases, AppCompatActivity someActivity) {
        this.dataList = dataFirebases;
        this.someActivity = someActivity;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        View view = LayoutInflater.from(viewGroup.getContext())
                .inflate(R.layout.item_label, viewGroup, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder viewHolder, int i) {
        final DataFirebase labelList = dataList.get(i);

        viewHolder.textLabel.setText(labelList.getLabel());

        viewHolder.linearLabel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                someActivity.getSupportFragmentManager()
                        .beginTransaction()
                        .setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_right, R.anim.enter_from_right, R.anim.exit_to_right)
                        .replace(R.id.container_layout, new TitleFragment())
                        .commit();
            }
        });
    }

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

    public class ViewHolder extends RecyclerView.ViewHolder {
        public LinearLayout linearLabel;
        public TextView textLabel;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            textLabel = itemView.findViewById(R.id.text_label);
            linearLabel = itemView.findViewById(R.id.linearLabel);
        }
    }

}

its perfectly fine before I try to install for the second time. the data are showed up just fine but the second time I try to install I got this error.
    java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference
     at com.example.parzival.flashcard.adapter.listAdapter.onBindViewHolder(listAdapter.java:45)
        at com.example.parzival.flashcard.adapter.listAdapter.onBindViewHolder(listAdapter.java:23)
        at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6781)
        at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6823)

How can I fix this?

A:

Going by the stack trace, your textview is null.
textLabel = itemView.findViewById(R.id.text_label);
linearLabel = itemView.findViewById(R.id.linearLabel);
Make sure that your text_label / linearLabel id belongs to R.layout.item_label.

