I'm a novice programmer so feel free to comment on things that make no sense so that I can learn.
I'm working on a coffee shop finder android app that makes calls to the SimpleGeo API to get each place of interest. I'm having trouble thinking up a way to store the returned JSON data in a way that I can use for my purposes. I need to do 2 things with the data: first, I need a map overlay class to access it so I can draw markers for each coffee shop (which I'm okay with); second, I need to display the data in a list view.
The API call:
/** Queries SimpleGeo with current location **/
private void getJSONData() {
SimpleGeoPlacesClient client = SimpleGeoPlacesClient.getInstance();
client.getHttpClient().setToken(oauth_key, oauth_secret);
double radius = 25;
try {
client.search(lat, lng, "coffee", null, radius,
new FeatureCollectionCallback() {
public void onSuccess(FeatureCollection collection) {
try {
features = collection.toJSON();
} catch (JSONException e) {
System.out.println(e.getMessage());
}
}
public void onError(String errorMessage) {
System.out.println(errorMessage);
}
});
} catch (IOException e) {
System.out.println(e.getMessage());
}
}
Parsing the data:
private void parseJSONData() throws JSONException {
for (int i = 0; i < features.length(); i++) {
JSONObject feature = features.getJSONObject(i).getJSONObject(
"feature");
}
}
I'm currently trying to create java objects out of the data using GSON outlined in this tutorial. Would SQLite be appropriate for this? Any pro-tips would be greatly appreciated.
Thanks.
Assuming you are working with android, you can use google map view
view,com.google.android.maps.MapView http://developer.android.com/resources/tutorials/views/hello-mapview.html
and ListView http://developer.android.com/reference/android/widget/ListView.html
I dont see how SQLite fits in here , unless you plan to store the places across app restarts. All you need to do is extract place information from JSON and do whatever you want with that data.