title: Android Volley Synchronize Server SQLite
body: <p>I am new to android development, just started with sqlite.</p>
  
  <p>Working on location app that should retrieve locations from mongo server, and populate local SQLite db.
  Listview, Search queries etc.. should use local db data.</p>
  
  <p>I am using volley library for my networking.</p>
  
  <p>Questions:</p>
  
  <p>1- After getting volley response, how do i populate sqlite?</p>
  
  <p>2- How do I send updated location data from server to device?
      (I dont need to update server with device info.)</p>
  
  <p>3- How do i ensure sqlite only gets updated, not overwriten from server everytime?</p>
  
  <p>I have seen examples using asynctask, syncadapter etc... But at this 
  point in project i cannot change my code from volley.</p>
  
  <p>My volley code below (currently parses json to object):</p>
  
  <pre><code>    private void getResource() {
      RequestQueue rq = Volley.newRequestQueue(this);
      JsonArrayRequest jObjR = new JsonArrayRequest(url_all_points, new Response.Listener&lt;JSONArray&gt;() {
  
          @Override
          public void onResponse(JSONArray response) {
              parseJSON(response);
  
          }
      }, 
      new Response.ErrorListener()
      {
           @Override
           public void onErrorResponse(VolleyError error) {           
              Log.d("Error.Response", error.toString());
         }
      }
  );
  
  rq.add(jObjR);
  }
  
  private void parseJSON(JSONArray response) {
      try {
          for (int i = 0; i &lt; response.length(); i++) {
              try {
                  JSONObject jsonObj = response.getJSONObject(i);
                  JSONObject coord = jsonObj.getJSONObject("coord");
                  MyLocation wj = new MyLocation();
                  wj.setTitle(jsonObj.optString("name"));
                  wj.setLat(coord.optDouble("latitude"));
                  wj.setLng(coord.optDouble("longitude"));
                  mLocations.add(wj);
                  LatLng location = new LatLng(wj.getmLat(), wj.getmLng());
                  mMap.addMarker(new MarkerOptions().position(location)
                        .title(wj.getTitle()));
  
              } catch (JSONException e) {
                  e.printStackTrace();
              }
          }
      } catch (Exception e) {
      }
  }
  </code></pre>