I'm creating an application in Android, and I also have a virtual server in Amazon Web Services, because I'm trying to connect to a database hosted in there from my Android application; I'd like to know how could I connect to the AWS database (Microsoft SQL Server), I understand that the servers in AWS are visible publicly, but I'm lost here, Could you provide me some guidance on this? thanks!
Your best bet is to create a web service layer between your Android app and your back-end database. That way, your Android app talks to the web service via the HTTP protocol, and the web service (running on a web server with access to your SQL Server) talks to the database. This is the most common method for achieving the database connectivity you need.
You create your web services using whichever web technology you are most comfortable with; .NET, PHP, ColdFusion, or whatever. So-called RESTful web services are a nice way to do this. You can read about building RESTful web services with .NET here. Hope it helps. Good luck with your app.
Related
i want to build an android application and i need to save and retrieve data from sql server database
so i need to do that with web service
i dont have knowledge in web services and how they are done
so can you help me what is the best way to do the web service and connect my android client with sql database
That's a pretty broad question, but here are the basics. A web service is a program or app that runs on a web server, usually exposed to the internet, or within a company's LAN on their intranet. Web Services can be built using ASP.NET or JAVA or PHP. I've used ASP.NET, specifically Web API 2.0, and Entity Framework. Entity Framework makes it very easy to connect your Web Service to your SQL Server database. With Web API and Entity Framework, you can create your web service and connect it to your database with basic Read/Add/Update/Delete capability in 1-2 hours.
Once you write your web service, you need to publish it on a Web Server as a Web App. I typically publish to an IIS Web Server (also Microsoft). For that you need a Website Hosted account with a Microsoft based server. Microsoft can host your Web Service using the Azure Cloud service. You can check out some tutorials for building your Web Service using the technologies mentioned and deploying to the Web using Azure. You can get a free Azure account to start with. Then, if you need to use it for a long time, you might need to pay for hosting fees.
This is probably the easiest and best way for you to get started, particularly if you are new to web services.
Good Luck!
Here is a tutorial using the technologies I've mentioned, except for Azure. But you should be able to find a tutorial for publishing a web service to Azure separately.
https://www.c-sharpcorner.com/article/asp-net-web-api-crud-logics-using-entity-framework-without-writing-single-code/
I'm creating my first android app. My app works in the following way:
User log into the app.
The login details is on an online server which is SQL Server 2008 R2
The server will return data to the app and the data the data will be stored on the app's database.
The problem I am facing is how should i connect to Sql server database. I researched on this topic and found out that I need to use some service. Can someone suggest as to what service should i use? A normal .NET web service, WCF service or Java Service.
I also need to know how to consume this service in my app.
Softwares I have with me:
Visual Studio 2008
SQL Server 2008 R2.
Android Development Kit & Eclipse
SQLite
Please help me.
I highly recommend the Asp.Net Web API for this:
"ASP.NET includes ASP.NET Web API for creating rich REST-ful Web Services that return JSON, XML, or any kind of content the web supports! ASP.NET Web APIs can provide data services to mobile apps like Windows Phones, iPhones, Android and more. ASP.NET Web APIs can be used in any ASP.NET Web Application, including ASP.NET MVC, Web Forms, or Web Pages – it's all One ASP.NET."
http://www.asp.net/web-api
Just to get you the general overview here;
You do not connect your (Android) app directly to the remote SQL database/server. Android, nor any other mobile platform, provides a steady and reliable interface for doing so.
Secondly, what you want to make indeed is a (REST) web-service.
As long as your needs are simple (passing along a bit of simple data between your app and your database) this means nothing more then having some web language take up some GET or POST variables and putting them in the database for you. And the same the other way around.
You can do this in any (web)language. The choice for language might be most influenced by the server you want to run in on, and what languages it already supports.
I have an Android application and I want to move my local database in the cloud. I decided for a SQL database and not for a NoSQL, because I want to execute complex queries. I created a database instance in RDS from Amazon and I populated the database.
Now I want to connect my mobile app to my cloud database. I saw samples for NoSQL database connection, but I wasn't able to find examples for RDS. I saw that it is recommended to create a web service and connect to that web service, but it seems much more complicated than using a NoSQL and this doesn't feel right.
Does Amazon offer some API/service for Android - RDS connection? Do you know any sample code that handles this aspect?
Does Amazon offer some API/service for Android - RDS connection?
No. AWS does not currently have an API for interacting with an RDS instance.
Do you know any sample code that handles this aspect?
You may want to access your database with PHP and get a JSON response. If your RDS instance is using MySQL then you’re in luck. There is already a lot of documentation on connecting Android to MySQL using PHP. You can get great sample code and instructions on this blog post.
Here is a very popular reference for connecting Android and MySQL.
I am developing social networking app on android.Rough idea of my app is that when user launches an app it will get all users of this app in near by location.So for storage purpose of users data I want to use web server. I don't have an idea what is best way to start with.Should i use Amazon web services ? (S3,Ec2) I was surfing internet got these buzz words.
Please guide me what is best approach for database storage ? Should i write my own server api ? or What ?
These are some general things you will have to do:
Buy some server space where you can host your server (this is the amazon ec2, etc). If you need a fancy domain name, buy that too, and map it to IP address of the server that you brought (optional).
Setup a db of some kind on this server to store your data (msql)
Write wrapper web services (php, jsp, etc) which will expose apis to access your data remotely. For security reasons, you should also have some authentication using some token passing mechanism.
Access the data on your server remotely using the APIs you created in the web service.
I personally favor using a MySQL database with PHP to interface between the app and the backend! Your app can send requests to PHP and then your PHP webservice would write/read to the database and then return JSON to your app.
I would say this is a very subjective question though as there as so many ways that you can write a web service.
First time working with android. I'm look for a way that an android app can connect to a remote database. However, this is on a closed network with no internet connection. Just the phone and the server.
I wanted to know the best way to connect, if its through JDBC or if its possible through android's SQLite class, or something else?
The phone is running android 2.1 and the database is a MySQL database.
Any guidance is much appreciated.
Thanks,
As long as the device is connected to the network, which would have to be via wifi, you can access a MySQL database hosted somewhere on the network just like you normally would.
My advice would be to set up a RESTful web service on the server which hosts the database. Your Android client application can communicate with this web service using HTTP requests and the web service can talk directly to the database. I'd say this is the most common approach for working with remote databases when it comes to Android.
Android Client <==> RESTful Web Service <==> MySQL Database
Android has a couple different ways to communicate with a web service: HttpClient and HttpUrlConnection. I think the latter is generally the most preferred way nowadays.
As far as I know, JDBC is unsupported for Android, and the Android SQLite API is strictly for using an embedded SQLite database.