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
Related
I am making an e-commerce android application and faced a major issue.I am fetching data for display through remote server and using JSON format.There will be many images may be 40-60 images and some text content for a activity.Now what i do uptil now is that firstly i fetches json data from server which also contains image link with name in it.After that using glide i fetches all the images and show in it.During development phase,it works fine on localhost but when i deployed all backened files on server then a major issue arises.It does not fetches data and takes too long.My backened API is working i checked them in browser and postman.What i am doing wrong here ? Does too much network request gives this issue?And main point is that server and all the php and sql files are working fine.
I am using android studio to fetch data from a cPanel/server and show in my android app. Problem is, data does not come from one specific server. But when I changes the server by changing the URL, the app works and data is showing. I uses same table and data in both server.
What could be the prob??
In my android application im using web-service to get information about food the problem that if i write appl instead of apple,row,skin it dosent fill automatically and an error message will be shown,, what i did i stored 2000 name from web service in sqlite and search through them is it wrong to do this ? and how can i search with misspelling in web-service without the error message ?
The api url http://api.nal.usda.gov/ndb/search/?format=json&q=apple&sort=n&max=25&offset=0&api_key=DEMO_KEY
Salam Enas,
If the data do change frequently (like a movies list) then it's not ok to store it in the sqlite and it's better to be stored in the server database.
If the data does not change frequently, then it's ok to store them on the sqlite database although the app size will increase by 2 Mb which is a drawback.
You may also want to consider other APIs if you are not committed to use this one.
When storing data on the server, HTTP requests burden can be alleviated by caching data on the mobile.
good luck :)
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.
I am designing a restaurant based app which has lots of images.
Please tell me:
How should I save images in the database i.e. in which format so that time of retrieval and display in the app is minimum? (Note: This database is a MySQL and located on an external server).
How should I retrieve them, i.e. which method to go for (JSON, etc)?
Dont use remote database server connection from application directly it may lead to slow performance . Instead use webservices as a intermediator between the database and your application. Your app should call a webservice which will internally query your database and return you the response . First response can be XML or JSON , but i would personally recommend you for the JSON as very fast from XML . Your first webservice response will return only the urls for images that you should download asynchronously so that UI thread is not hanged up .