-1

I want to develop an Android application which would connect to a SQL Database which is already created . We developed this news site : e-Cmunio. This site is based on a SQL Database that already has a lot of news and stuff in. For now, what we want for our Android app is to connect to that database and show some random news in a listView.

The problem is that I don't know how to connect to it from Android.

I have already read about some WebServices, but I have no idea from where to start. We ( me and a friend ) are in HighSchool. The site was developed in C#. We are new in Android and java, but we are familiar with algorithms and data structures. Could you please give me some tutorials and entry-level information about how can we access our DataBase?

Sorry if I hasted your time, but I really have no idea where to start from.

Termininja
  • 6,620
  • 12
  • 48
  • 49
user2535042
  • 15
  • 1
  • 5
  • the problem is that you cannot connect from android to SQl server, the site you want to connect should have some web-services, or at least some API, you need to use them, I don't think so they provide the direct access to database, btw, welcome aboard –  Jun 29 '13 at 17:53

3 Answers3

0

What you want to do is make a webservice on your server side that connects to your database and returns whatever you want to return in your favorite format(XML / JSON).

Next, on Android(client side) you want to have an AsyncTask to access that webservice and fetch your news and save them to your Android SQLite Database.

Later like you suggested you can load those news from a cursor directly to your listView with a Listview adapter.

You can read about Saving data in SQLite here: http://developer.android.com/training/basics/data-storage/databases.html

You can read about AsyncTask here: http://developer.android.com/reference/android/os/AsyncTask.html

Rui Santos
  • 537
  • 3
  • 15
0

The easiest way is to use PHP to parse ur data to JSon and read that data and parse it in ur Android phone..

SQL to PHP to JSon to read from. http://www.bin-co.com/php/scripts/sql2json/

Parse JSON to Android http://www.vogella.com/articles/AndroidJSON/

  • Hi! I made this php script :http://ideone.com/4kY7Cz. Now I am wondering how can I actually use this script? How can I put this php file in my server (SQL Server 2005) ? Please, help me! – user2535042 Jun 30 '13 at 15:15
0

You already have an elaborate answer in connect to sql server from android.

Web services define interface for your website in a standardized way, so that other websites/applications can access it. It is more extensible and generic solution then directly accessing server's database. Simple web service can be just an XML or a JSON file generated after querying your website with specific parameters. So as an exercise in your case I would implement handling of specified URL in your C# server code and generate XML file with your news (query in URL) and then just open your page with this URL on your android app and read this XML. When your app will become more complex, then you can start moving to some standard web service solution.

Community
  • 1
  • 1
plw
  • 59
  • 1