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 dosen
t 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
Asked
Active
Viewed 185 times
0

userr12
- 65
- 1
- 8
-
what adapter are you using? post its code – pskink Sep 04 '16 at 05:55
-
ArrayAdapter
adapter = new ArrayAdapter – userr12 Sep 04 '16 at 06:07(MainActivity.this, android.R.layout.simple_dropdown_item_1line, myData); autoCom.setAdapter(adapter); -
see [this](http://stackoverflow.com/a/19860624/2252830) – pskink Sep 04 '16 at 06:09
-
sorry, but i didn`t get that, if i search like this http://api.nal.usda.gov/ndb/search/?format=json&q=app&sort=n&max=25&offset=0&api_key=DEMO_KEY there will be an error message so what is constraints ? – userr12 Sep 04 '16 at 06:25
-
then check inside `runQuery` if the root element is "list" or "errors" – pskink Sep 04 '16 at 06:33
-
So it depends on the api and this api doesn`t allow searching with one letter ? – userr12 Sep 04 '16 at 06:53
-
yes, it seems so – pskink Sep 04 '16 at 06:54
-
thanks for help but is it ok to save it on sqlite ? – userr12 Sep 04 '16 at 06:59
1 Answers
0
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 :)

WadeeSami
- 59
- 4