Thursday, 17 October 2013

get location data logic from json

logic code
please run in AsyncTask  doinbackground method



JSONArray locationsobject = json.getJSONArray("locations");
String latitude = "";
String longitude = "";
String city = "";
String state = "";
String country = "";
String id = "";
String street = "";
String zip = "";

for (int i = 0; i < locationsobject.length(); i++) {
JSONObject i_Loc = locationsobject.getJSONObject(i);
System.out.println("location object:" + i_Loc);

try {
latitude = i_Loc.getString("latitude");
System.out.println("latitude :" + latitude);
} catch (Exception e) {

e.printStackTrace();
}
try {
longitude = i_Loc.getString("longitude");
System.out.println("longitude :" + longitude);
} catch (Exception e) {

e.printStackTrace();
}
try {
city = i_Loc.getString("city");
System.out.println("city name :" + city);
} catch (Exception e) {

e.printStackTrace();
}
try {
state = i_Loc.getString("state");
System.out.println("state :" + state);
} catch (Exception e) {

e.printStackTrace();
}
try {
country = i_Loc.getString("country");
System.out.println("country :" + country);
} catch (Exception e) {

e.printStackTrace();
}
try {
id = i_Loc.getString("id");
System.out.println("id :" + id);
} catch (Exception e) {

e.printStackTrace();
}

try {
street = i_Loc.getString("street");
System.out.println("street :" + street);
} catch (Exception e) {

e.printStackTrace();
}
try {
zip = i_Loc.getString("zip");
System.out.println("zip :" + zip);
} catch (Exception e) {

e.printStackTrace();
}
}

1 comment:

  1. casino.bet review - DRMCD
    Read 의왕 출장안마 our Casino.bet review and find out 포천 출장샵 the latest casino promotions 동두천 출장마사지 and offers. Check out our review 부천 출장안마 of the casino.bet. Casino.bet 동해 출장안마 Casino.bet Casino.bet Sportsbook.

    ReplyDelete