title: I'm reading some data from Firebase database but it returned object is null
body: <p>Here is my firebase structure
  <a href="https://i.stack.imgur.com/mQuq4.jpg" rel="nofollow noreferrer">Fire Base Structure</a></p>
  
  <p>I am trying to fetch phone value from firebase but it is giving null.</p>
  
  <blockquote>
    <p>java.lang.NullPointerException: Attempt to invoke virtual method 'com.google.firebase.database.DatabaseReference com.google.firebase.database.DatabaseReference.child(java.lang.String)' on a null object reference</p>
  </blockquote>
  
  <pre><code> //getting user id value
      SharedPreferences settings = getSharedPreferences("myapp", MODE_PRIVATE);
  
  
      // Reading from SharedPreferences
  
      String uid = settings.getString("uid", "");
      userId = uid;
      mFirebaseDatabase.child("users").child(userId).child("phone").addValueEventListener(new ValueEventListener() {
          public void onDataChange(DataSnapshot dataSnapshot) {
              // This method is called once with the initial value and again
              // whenever data at this location is updated.
              phone = dataSnapshot.getValue(String.class);
              Log.d(TAG, "Value is: " +phone);
  
          }
  
          @Override
          public void onCancelled(DatabaseError error) {
              // Failed to read value
              Log.w(TAG, "Failed to read value.", error.toException());
          }
  
      });
  
  textview.setText(phone);
  </code></pre>
  
  <p>Please give some suggestion i don't know why it is returning null 
  Thanks</p>