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 6803233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:19:10+00:00 2026-05-26T19:19:10+00:00

I download json data from server and I want to save them to a

  • 0

I download json data from server and I want to save them to a file in android mobile.

How can I do it with external storage? When I save them I also want to search in file for specific data. Is there a better way to do that than external storage?

//parse json data
try{
    JSONArray jArray = new JSONArray(result);
    JSONObject json_data = null;
    category = new String[jArray.length()];
    name = new String[jArray.length()];
    date = new String[jArray.length()];
    content = new String[jArray.length()];

    for(int i=0;i<jArray.length()+2;i++){
        HashMap<String, String> map = new HashMap<String, String>();

        if(i==0){ 
            if(category8 == "All"){
                map.put("id",  "5");
                map.put("name", "              All Posts");
                map.put("latitude", "");
                map.put("longitude", "");
                map.put("date", "");
                map.put("content", "");
                mylist.add(map);
            } else {
                json_data = jArray.getJSONObject(i);

                category[i] = json_data.getString("category");
                map.put("id",  "5");
                map.put("name", "              "+category[i]);
                map.put("latitude", "");
                map.put("longitude", "");
                map.put("date", "");
                map.put("content", "");
                mylist.add(map);
            }
        } else if(i<jArray.length()+1) {
            json_data = jArray.getJSONObject(i-1);

            id = json_data.getInt("post_id");
            name[i-1] = json_data.getString("username");
            latitude = json_data.getDouble("latitude");
            longitude = json_data.getDouble("longitude");
            date[i-1] = json_data.getString("post_date");
            content[i-1] = json_data.getString("post_content");

            map.put("id",  String.valueOf(id));
            map.put("name", name[i-1] + " wrote:");
            map.put("latitude", "Latitude: " + latitude);
            map.put("longitude", "Longitude: " + longitude);
            map.put("date", "Date: " + date[i-1]);
            map.put("content", content[i-1]);
            mylist.add(map);
        }

        if(i==jArray.length()+1) {
            map.put("id",  "5");
            map.put("name", "");
            map.put("latitude", "");
            map.put("longitude", "");
            map.put("date", "");
            map.put("content", "");
            mylist.add(map);
        }
     }
} catch(JSONException e1) {
    Toast.makeText(getBaseContext(), "No posts found" ,Toast.LENGTH_LONG).show();
} catch (ParseException e1) {
    e1.printStackTrace();
}
  • 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-05-26T19:19:11+00:00Added an answer on May 26, 2026 at 7:19 pm

    JSON needs to be parsed in order to get information from it. So saving a JSON-Request and parsing it every time you need information from it is generally a bad idea.

    Instead, you’ll want to parse it once, get your desired information, and save them somewhere you can easily access them. Where and how to save them differs from what you want to do with it:

    • If you are planing to extensively search through it or require just some parts of it’s information, a Database should be your best option.
    • Otherwise, if you simply want to store a couple of values, you might want to pick an easier format to parse it quicker (like CSV).

    Also, you said you wanted to store those things on the external storage. Generally speaking: Storing things which belong to your application on the external storage is a bad idea. There are however some cases where it makes sense:

    • Your app want’s to share certain things (and you don’t want to use a ContentProvider)
    • Your app needs a large amount of files which can’t be stored in the internal storage.

    Keep in mind that every file saved on the external storage can be manipulated! Also, you can’t rely on the external storage because some users might don’t have one.

    In cases other then the listed above, it’s a better idea to use the internal storage.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First, I'm using an NSURLConnection to download JSON data from twitter. Then, I'm using
I want to send a large amount of cached json data from an import
I'm trying to grab data from a JSON on an external site but the
I want to fetch data from my web server, and put it into a
I am using NSURLConnection to download gzipped JSON from server. Is it possible to
I want to write a android application which needs data from the web. This
My app currently requests a JSON file with some text and other data from
In my app I have to download JSON data from numerous web services. The
I have created a library which can download JSON data which is then placed
I try to get data from server http://someserver12345.com If i download it for example

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.