Json parse much time - android

I am developing a map application and I parse one json file and after I take some data from this file I use the data to parse another json twenty times and I do this in one asynctask and it takes too long if I dont connect to internet on wifi(with mobil network).What is the best approach to reduce the time elapsed?Can anyone help?

Related

Best Practices for fetching json from server for android app

I have an Android app with 1 activity and 3 fragment opened in tablayout.
When a user open the app, the mainActivity fetch a json file from the server to check if the app version still in use and the first fragment fetch also a separate json file to feed the views. Every fragement fetch a separate json file to feed the there views with data.
The problem that I have is, that when the app has more than 100 active user, the json file did not get loaded and the okhttp get a timeOutException when trying to fetch the json file from the server. Basically when a user open the app, 4 json files will be fetched from the server, so I think the server has problem responding to all the requests.
So my question, what is the best practice to resolve such a performance problem, beside upgrading the server itself.
Thank you in advance

Is it better to parse json every time in android

I am creating an android ecommerce app with WP REST API and the json I get from that API, I need to store it for offline purpose. So what is a better approach save parsed data in to sqlite and just show it from there or save the json string and parse it every time it needs to be shown?
No, you must only parse before adding that to sqlite. Why to do extra same work every time. Not only it is time consuming but also memory over head for conversion.
Parse JSON and store it into SQLite Database. Storing data into SQLite will be better to handle in Offline mode.

Rss to Json Api Android Studio

I'm working on an Android studio project and till now I have successfully added some json feeds in my app.
However , i need to add one rss feed also to my app.
The easiest solution to me is to make an online conversion of the rss feed to json feed so I can parse my data with the previous code.
Google API is going to stop by 15th Dec 16' and yahoo query is down .
What would you suggest?
I'm about 5 hours now , trying to find a solution.
*I tried rss2json.com however after the first time fetching the data , the feed is refreshed after a long , very long time.
You can create your own toJson(xml) method and use XmlPullParser to read and retrieve the data you need to create a new Json object. I'm guessing you want to use your Json parser instead, but at this point you already have the data that you would be using for your application. So, just use an XML parser instead =).

Insert data in sqlite from server

I am trying to import some data from server to my android app. Server gets data from sql server and returns it throw a HttpRequest. I parse the data from HttpResponse and store it in sqlite database upon the JSONObject is parsed.
However the number of objects to be inserted is high and the operation may be canceled intentional(by pressing pause) or unintentional(internet problem). So I have below choices:
1- Ignore inserting into database after parsing JSONObject and wait for complete successful response from server: This solution is highly bad because if a problem occurs the user should start importing data again.
2- Make a feedback to server when I insert a row to database. So if I resume importing data just new records are imported from server: It is good but imposes extra network communication and also may affect performance.
3- Get one data packed file and try to parse it: So I am sure pausing the operation will not cause to data lost. But I prefer another solution rather than working with file.
What is the best way to handle this issue?
Thanks
I went through this choice two weeks ago.
I found the better way to manage these data is to build a web service in the server (for example, in PHP; i was using a wordpress blog), send to the web service an offset and limit request and then download the data in JSON format.
In this way, if you have 100 rows to query, you can tell the web service to give you the first 10 results, then you can parse and store them, and then, you can go back with another query asking the results from the row 11 to the row 20, and so on.
In this way, the app will manage many sequential requests (and the related low-weight JSON answers), instead of an extremely big JSON file.
You can also manage all these operation in background or with AsyncTask so, in the meantime, the user can work on the foreground activity.

Parsing XML performance issue Android

I send a request off to our server and receive a response from the server. The response contains information related to an image. The server returns the image as a base64 string. It is taking way to long (30-40 seconds per image) to parse out the data so I can pull the information I need to save and view the image. I am looking for suggestions on better ways that might help to speed up the process. I am currently using a SAX parser and the slow down is when the .parse function is called.

Categories

Resources