title: Android- Attempt to invoke virtual method 'double java.lang.Double.doubleValue()' on a null object reference
body: <p>There are two accounts in my app, family and elderly. And I want to retrieve the location of the elderly to the family account, then show it in a map. Now, I want to get the latitude and longitude. I have set the accounts in a pair.</p>
  
  <p>Here is the database structure.</p>
  
  <p><img src="https://i.stack.imgur.com/vJBHi.png" alt="">
  </p>
  
  
  
  
  
  <p>Update:</p>
  
  <p>The updated code:</p>
  
  <pre><code>private Button logout;
  private ImageButton buttonCurrent;
  private DatabaseReference mDatabase;
  private FirebaseAuth mAuth;
  private FirebaseUser user;
  private double longitude;
  private double latitude;
  private String currentUserId;
  private com.google.firebase.database.Query mQueryMF;
  
  
  //Our Map
  private GoogleMap mMap;
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      mAuth = FirebaseAuth.getInstance();
      user = mAuth.getCurrentUser();
      currentUserId = user.getUid();
      mDatabase = FirebaseDatabase.getInstance().getReference();
  
  
      setContentView(R.layout.activity_main__family);
  
      SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
              .findFragmentById(R.id.map);
      mapFragment.getMapAsync(this);
  
      logout = (Button) findViewById(R.id.logout);
      buttonCurrent = (ImageButton) findViewById(R.id.buttonCurrent);
  
  
      buttonCurrent.setOnClickListener(this);
  
      logout.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              FirebaseAuth.getInstance().signOut();
              startActivity(new Intent(MainActivity_Family.this, HomeActivity.class));
          }
      });
  
  
  }
  private void getCurrentLocation() {
     mQueryMF = mDatabase.child("users").child("familyId").equalTo(currentUserId);
  
      mQueryMF.addValueEventListener(new ValueEventListener() {
          @Override
          public void onDataChange(DataSnapshot dataSnapshot) {
              latitude = 
  dataSnapshot.child("latitude").getValue(Double.class);  
              longitude = 
  dataSnapshot.child("longitude").getValue(Double.class);
              //String to display current latitude and longitude
              String msg = latitude + ", "+longitude;
  
              //Creating a LatLng Object to store Coordinates
              LatLng latLng = new LatLng(latitude, longitude);
              //Adding marker to map
              mMap.addMarker(new MarkerOptions()
                      .position(latLng) //setting position
                      .draggable(true) //Making the marker draggable
                      .title("Current Location")); //Adding a title
  
              //Moving the camera
              mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
  
              //Animating the camera
              mMap.animateCamera(CameraUpdateFactory.zoomTo(15));
          }
  
          @Override
          public void onCancelled(DatabaseError databaseError) {
          }
      });
  
  }
  
  //Function to move the map
  /*private void moveMap() {
  
  
  
  
      //Displaying current coordinates in toast
      //Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
  }*/
  
  @Override
  public void onMapReady(GoogleMap googleMap) {
      mMap = googleMap;
      LatLng latLng = new LatLng(-34, 151);
      mMap.addMarker(new MarkerOptions().position(latLng).draggable(true));
      mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
      mMap.setOnMarkerDragListener(this);
      mMap.setOnMapLongClickListener(this);
  }
  
  @Override
  public void onConnected(Bundle bundle) {
      getCurrentLocation();
  }
  
  @Override
  public void onConnectionSuspended(int i) {
  
  }
  
  @Override
  public void onConnectionFailed(ConnectionResult connectionResult) {
  
  }
  
  @Override
  public void onMapLongClick(LatLng latLng) {
      //Clearing all the markers
      mMap.clear();
  
      //Adding a new marker to the current pressed position
      mMap.addMarker(new MarkerOptions()
              .position(latLng)
              .draggable(true));
  }
  
  @Override
  public void onMarkerDragStart(Marker marker) {
  
  }
  
  @Override
  public void onMarkerDrag(Marker marker) {
  
  }
  
  @Override
  public void onMarkerDragEnd(Marker marker) {
      //Getting the coordinates
      latitude = marker.getPosition().latitude;
      longitude = marker.getPosition().longitude;
  }
  
  @Override
  public void onClick(View v) {
      if(v == buttonCurrent){
          getCurrentLocation();
      }
  }
  </code></pre>
  
  <p>The error happens in getting the latitude in getCurrentLocation function</p>