title: NullPointerException is coming on Google map loading method
body: <pre><code>public void drawMarker(ArrayList&lt;Datamodel&gt; arrModel) {
      if(map!=null)
      {
  
      String lat = "";
      String lng = "";
  
      SharedPreferences prefs = getActivity().getSharedPreferences("Value",
              Context.MODE_PRIVATE);
  
      locationEnabledisablevalue = prefs.getString("GpsEnableValue", "1");
  
      if (!locationEnabledisablevalue.equals("1")) {
          map.clear();
          return;
      }
  
      for (int i = 0; i &lt; arrModel.size(); i++) {
          // Drawing marker on the map
          Datamodel datamodel = arrModel.get(i);
  
          // Getting the latitude of the i-th location
          lat = datamodel.lat;
  
          // Getting the longitude of the i-th location
          lng = datamodel.lon;
  
          LatLng point = null;
          if (lat != "" &amp;&amp; lng != "") {
              point = new LatLng(Double.parseDouble(lat),
                      Double.parseDouble(lng));
          }
          // Creating an instance of MarkerOptions
          MarkerOptions markerOptions = new MarkerOptions();
  
          // Setting latitude and longitude for the marker
          markerOptions.position(point);
          markerOptions.title(datamodel.contactName);
  
          if (datamodel.id
                  .equals(((HomeActivity) getActivity()).NotifcationRecciverid)) {
  
              String ContactLat = "";
              String ContactLng = "";
  
              String Notificationlat = ((HomeActivity) getActivity()).notifcationlat;
              String Notificationlng = ((HomeActivity) getActivity()).notifcationlng;
              String Notifcationreccvierid = ((HomeActivity) getActivity()).NotifcationRecciverid;
  
              try {
                  DataBaseManager db = new DataBaseManager(getActivity());
                  Cursor cursor = db.fetchContactInfo(Notifcationreccvierid);
  
                  if (cursor != null &amp;&amp; cursor.moveToFirst()) {
                      ContactLat = cursor
                              .getString(cursor
                                      .getColumnIndex(DataProviderConstants.CONTACT_LAT_COLUMN));
  
                      ContactLng = cursor
                              .getString(cursor
                                      .getColumnIndex(DataProviderConstants.CONTACT_LON_COLUMN));
  
                      cursor.close();
                  }
              } catch (NullPointerException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
  
              float distance = AdapterHome.findDistance(
                      Double.parseDouble(Notificationlat),
                      Double.parseDouble(Notificationlng),
                      Double.parseDouble(ContactLat),
                      Double.parseDouble(ContactLng));
              String time = ((HomeActivity) getActivity()).NotifcationDatetime;
              markerOptions
                      .snippet(((HomeActivity) getActivity()).nOtifcationMessge
                              + "  " + Functions.curentdatetimeprint(time));
  
              marker = map.addMarker(markerOptions);
              LatLng myPoint = new LatLng(Double.parseDouble(ContactLat),
                      Double.parseDouble(ContactLng));
              // // Move the camera instantly to hamburg with a zoom of 15.
              map.moveCamera(CameraUpdateFactory.newLatLngZoom(myPoint, 15));
              //
              // // Zoom in, animating the camera.
              map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);
              // if (distance &lt; 250) {
              marker.showInfoWindow();
              // }
              // }
  
          } else {
              markerOptions.snippet(datamodel.phoneNumber);
              map.addMarker(markerOptions);
  
          }
      }
      }
  </code></pre>
  
  <p>here is my code display marker on Google map . in public void onResume() method i m calling this drawMarker(arrModel); but some times application is crashing and showing error Logcat issue at line </p>
  
  <pre><code> .SharedPreferences prefs = getActivity().getSharedPreferences("Value",
                  Context.MODE_PRIVATE);
          locationEnabledisablevalue = prefs.getString("GpsEnableValue", "1");
  </code></pre>
  
  <p><br></p>
  
  <p>Logcat:-</p>
  
  <pre><code>   12-15 10:29:02.494: E/AndroidRuntime(16303): FATAL EXCEPTION: main
      12-15 10:29:02.494: E/AndroidRuntime(16303): java.lang.NullPointerException
      12-15 10:29:02.494: E/AndroidRuntime(16303):    at com.locii.fragment.FragHome.drawMarker(FragHome.java:347)
      12-15 10:29:02.494: E/AndroidRuntime(16303):    at com.lociiapp.HomeActivity$UpdateUserLocation.onPostExecute(HomeActivity.java:530)
      12-15 10:29:02.494: E/AndroidRuntime(16303):    at com.lociiapp.HomeActivity$UpdateUserLocation.onPostExecute(HomeActivity.java:1)
      12-15 10:29:02.494: E/AndroidRuntime(16303):    at android.os.AsyncTask.finish(AsyncTask.java:631)
      12-15 10:29:02.494: E/AndroidRuntime(16303):    at android.os.AsyncTask.access$600(AsyncTask.java:177)
      12-15 10:29:02.494: E/AndroidRuntime(16303):    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
      12-15 10:29:02.494: E/AndroidRuntime(16303):    at android.os.Handler.dispatchMessage(Handler.java:99)
      12-15 10:29:02.494: E/AndroidRuntime(16303):    at android.os.Looper.loop(Looper.java:137)
      12-15 10:29:02.494: E/AndroidRuntime(16303):    at android.app.ActivityThread.main(ActivityThread.java:5136)
      12-15 10:29:02.494: E/AndroidRuntime(16303):    at java.lang.reflect.Method.invokeNative(Native Method)
      12-15 10:29:02.494: E/AndroidRuntime(16303):    at java.lang.reflect.Method.invoke(Method.java:525)
      12-15 10:29:02.494: E/AndroidRuntime(16303):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
      12-15 10:29:02.494: E/AndroidRuntime(16303):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
      12-15 10:29:02.494: E/AndroidRuntime(16303):    at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>Please tell me  how to fix this issue i am unable to set Null Pointer exception .</p>