0

I have created a mobile app in eclipse and a database on phpmyadmin.

I want the information stored in the database to be displayed in the app. For example if a user makes a search on the app they enter their search and their location and the app gives them the information related to their search that also matches their location. The information has then been taken from what is in the database.

What is the best way to do this? Or does anyone have any tutorials of anything similar?

Ed Holloway-George
  • 5,092
  • 2
  • 37
  • 66
Tmcc
  • 1
  • 1
  • 5

1 Answers1

0

first of all, you should look at how a client / server infrastructure is handled when using android.

you will need a PHP custom API that should give you the data in your desired format ( i reccomend json), and you should create your app in a way that the retrieval of the data runs smoothly and advising the user of the process, (optional: the progress), and the sucess of the retrieval.

please take a look at this website:

http://www.techrecite.com/how-to-create-json-using-data-from-mysql-database/

basically, the "schematic" of my recomended client - server app is this:

android:

  1. user enters activity.
  2. show a progressDialog so the user doesn't die expecting something to happen.
  3. using any http connection library ( i reccomend Android Async http) make a petition to "yourserver.com/yourapi.php?yourametres" and expect a response.
  4. parse the sucess data with a parser class ( transform it into a java object. GSON is a good library for doing that).
  5. Using Greenrobot's eventbus library, send the activity an event with the parsed data.
  6. update listview adapter / textviews / whatever with the recieved data, remove the progressDialog, and let the user have fun!.

hope it helps.

https://github.com/greenrobot/EventBus

http://loopj.com/android-async-http/

https://code.google.com/p/google-gson/

CptEric
  • 897
  • 9
  • 23