Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8259829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:57:10+00:00 2026-06-08T02:57:10+00:00

I am having an application in which I want to get json data from

  • 0

I am having an application in which I want to get json data from a php web server to android mobile. What I am having is a URL and hitting that URL gives me the json data like
{"items":[{"latitude":"420","longitude":"421"}]}. But I want to retrieve this json format in my android mobile and get the values of latitude and longitude from json format.

How can we get that on android mobile..?

Thanks in advance..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T02:57:12+00:00Added an answer on June 8, 2026 at 2:57 am

    First do URL Connection

    String parsedString = "";
    
        try {
    
            URL url = new URL(yourURL);
            URLConnection conn = url.openConnection();
    
            HttpURLConnection httpConn = (HttpURLConnection) conn;
            httpConn.setAllowUserInteraction(false);
            httpConn.setInstanceFollowRedirects(true);
            httpConn.setRequestMethod("GET");
            httpConn.connect();
    
            InputStream is = httpConn.getInputStream();
            parsedString = convertinputStreamToString(is);
    
        } catch (Exception e) {
            e.printStackTrace();
        }
    

    JSON String

    {
    "result": "success",
    "countryCodeList":
    [
      {"countryCode":"00","countryName":"World Wide"},
      {"countryCode":"kr","countryName":"Korea"}
    ] 
    }
    

    Here below I am fetching country details

    JSONObject json = new JSONObject(jsonstring);
    JSONArray nameArray = json.names();
    JSONArray valArray = json.toJSONArray(nameArray);
    
    JSONArray valArray1 = valArray.getJSONArray(1);
    
    valArray1.toString().replace("[", "");
    valArray1.toString().replace("]", "");
    
    int len = valArray1.length();
    
    for (int i = 0; i < valArray1.length(); i++) {
    
     Country country = new Country();
     JSONObject arr = valArray1.getJSONObject(i);
     country.setCountryCode(arr.getString("countryCode"));                        
     country.setCountryName(arr.getString("countryName"));
     arrCountries.add(country);
    }
    
    
    
    
    public static String convertinputStreamToString(InputStream ists)
            throws IOException {
        if (ists != null) {
            StringBuilder sb = new StringBuilder();
            String line;
    
            try {
                BufferedReader r1 = new BufferedReader(new InputStreamReader(
                        ists, "UTF-8"));
                while ((line = r1.readLine()) != null) {
                    sb.append(line).append("\n");
                }
            } finally {
                ists.close();
            }
            return sb.toString();
        } else {
            return "";
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having one Gtk+ and C application in which i want to set
I'm making my first Android application and I'm having a problem for which I
I am having capture graph application which captures mp4 capture video , i want
i am having an application which can share Notes to evernote,it works fine i
I am developing application which is having Gujarati font in text-view but my problem
I have an IPhone application which is having a non consumable in app purchse
I'm having a problem compiling an application which uses Core-Plot in debug mode. It
I'm having trouble deploying .NET application which uses Microsoft Access automation. I've installed the
I ran dotTrace on my application (which is having some issues). IntPtr System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr, IntPtr,
I have a application in which I am using socket programming , having this(image)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.