I have a database in MS SQL 2014 containing my tables like login user table and data of user table.
Now I make the login app design for it, but how can I connect with MS SQL 2014 from Android?
I have a database in MS SQL 2014 containing my tables like login user table and data of user table.
Now I make the login app design for it, but how can I connect with MS SQL 2014 from Android?
You are looking for this on REST API communication stackoverflow.com/a/26573636/2413303 and if you want to look into something more advanced, here is a nifty project with sources and everything github.com/vyshane/rex-weather and don't forget the official guide developer.android.com/training/index.html and also use Otto vogella.com/tutorials/JavaLibrary-EventBusOtto/article.html and ButterKnife tikalk.com/…
I try to explain the basic Rest API communication below. Please note that below code is only an example and there are a lot to do in server-side for security, maintability, testability or any other architectural issues.
Firstly, you should create a service layer server using a server-side language like php, java, c# or others. Considering you use C# MVC. You can create a Web API project query your db and return the data as Json string which could easily be parsed in your Android App. Here is a sample;
public string GetRecords()
{
using (var context = new TestEntities())
{
return JsonConvert.SerializeObject(context.Records.ToList());
}
}
Then; you publish this API to IIS so that it is accessible through an URL like "http://localhost/Home/GetRecords".
In your Android application, you can call this URL via HTTP get or post to get the result as Json string. There are lots of sources how to call Rest API in Android such as this.
Then, you can parse the Json string to Android model and manipulate according to your needs.