I need to send all my contacts to server and return back only the contacts that are using my app.I am using HttpPost for sending data to the server. I am thinking of sending it as an string separated by delimiters or as NameValuePair. Is there any better way to do contact sync?
Asked
Active
Viewed 2,366 times
0
-
this is best way but NameValuePair is not so good if i have more then 5000 contacts then..?? so make json string and pass it on server. and you wants to send back contact to your apps all user?? then same way you can send back all contact to your user. – Dhaval Parmar Aug 15 '12 at 13:35
-
@DhavalSodhaParmar Okay thanks!I will try using json. What is your idea about sending as string with delimiters?So in php I can use explode for splitting it. – Maggi Aug 15 '12 at 13:43
-
no,in android app we use JSON parsing same way you have to parse JSON String on PHP side. in Explode & Implode PHP will take long time to process your code so use JSON Parsing. – Dhaval Parmar Aug 15 '12 at 13:48
-
Oh okay, you are right.It should not take more time. I will use JSON..thanks for your suggestion! – Maggi Aug 15 '12 at 13:53
1 Answers
1
Are you using a database? If so create a php webservice that connect to your database, make a query and return results according the criteria you need. then you need to encode the result in a json array and use json to connect your android app and get the results, here is an example how to use json with android:
http://www.vogella.com/articles/AndroidJSON/article.html
There are many more libraries you can use: gson/json/jackson... all similar, you can make a search on google and chose the one you like better
Instead of json you can use SOAP, I have never used it but you can try : http://code.google.com/p/ksoap2-android/
Direct database connection is not recommended on android

Dhaval Parmar
- 18,812
- 8
- 82
- 177

vallllll
- 2,731
- 6
- 43
- 77
-
I am using the mysql database.But I am not trying to connect directly from android. I am writing scripts in server that handles the request.So, as of now I want to send the contacts to the server and receive the response. Thanks for your suggestion, I will try the JSON for it! – Maggi Aug 15 '12 at 13:50