I am building an Android application with Kotlin. I am not very familiar with Databases and Backend in general, I have only used AWS DynamoDB and S3. I want to try something else and learn SQL. I want to connect my app to a Cloud SQL DB like MySQL or PostreSQL. I can't use SQLite because I want the app to be served remotely and be accessible by all the users. I don't need a server, instead I would like to use a server-less structure where I make queries to the DB on function calls from inside my App. How would I do that? I read online about services like planetscale and raiway.app but I can't find a way to connect to my tables there. Are they perhaps web-only?
If you have a remote back-end you can use retrofit https://square.github.io/retrofit/ otherwise you can use room library https://developer.android.com/training/data-storage/room.
I understand that you aren't going to use a Server but in the case where you have to make queries locally, i.e. you have your database on your PC, you must use retrofit and for doing this you must make a small API that will send you JSON and you can process your queries easily with that. If not, you can use room to connect to sqlite, a small database that is default on android phones.
Some Links :
https://square.github.io/retrofit/,
https://developer.android.com/training/data-storage/room.
Related
I have a lot of nice ideas to develop into Web and Mobile applications, most of them need an online DB communication. However, I don't know nothing how to configure a fresh DB server from the scratch and start queries and requesting it. Even with DB basis acquired during my graduation.
What I don't know is what to use. If I need a DBMS or build my own server from scratch (which I would like to avoid to save time).
So, I don't want to develop a DB server (back-end, such as PhP, Java, etc...). I need a ready-to-use back-end to send my queries and request to it.
Any suggestion, or tutorial how to configure it? Like deploying on AWS...
many thanks, in advance!!!
I've developed some card game apps that use databases for leaderboards and multiplayer data. I found that using http to access php scripts which in turn access mySQL databases and json encode the result certainly works and is reliable. You will need to write a bit of php and set up the databases but other than that it's quite straightforward. If you keep your http access in a seperate thread in the app you can do visual and input processing whilst waiting for the result.
You don't have to build database server yourself. Database services are available from some companies. Some are:
Amazon Relational Database Service (Amazon RDS)
Google Cloud SQL
Windows Azure SQL Database (SQL Azure)
Clear DB
I have been learning SQLite on Android and have done some tutorials on how to use it.
There is a question that I want to ask.
Is there a way to make my app connect to my MySQL database in a remote web server of mine so that it can read data and also write data to the database?
From what I've researched, SQLite cannot be used remotely and I would need some kind of Web service in between?
It's not easy to create a connection to MySQL from Android, if it's not impossible. With that, it's also not safe if for example someone decompiles your app they have access to your whole MySQL database if you don't limit it enough.
For those reasons, you can better use a (for example) PHP webservice to which the Android application sends all their requests. An example is available at http://www.helloandroid.com/tutorials/connecting-mysql-database.
I also suggest you use Android Asynchronous Http Client so you don't have to deal with connectivity issues and AsyncTasks yourself.
You can refer to this tutorial but you do need a web-server for it.
Request mechanism
Android App ----> webserver ------> database (mysql)
Respond mechanism
Android App <---- webserver <------ database (mysql)
Android App will use JSON or other to get the data and display it
You have to use Sqlite database and web Services both. First you have to save the data in local database i.e. SQLite database and then send this data to your server using web services and vice versa.
this link for web services
and this link for SQlite will help you understand.
Thanks.
I am trying to develop a real-time Android application where all contents are stored in server. So, they are available whenever a connection to Internet is available. Also, the application provides communication between users and conversations are stored in the server as well. Nothing is locally stored.
However, I am still cannot decide which database type I can use. I intended to use SQLite but I am not sure if I can really use it or not.
Could you please guide me to the proper database type to my application.
Appreciate your time and efforts.
As its upto you which database you use.
you may Install Lamp (For Linux) or WAMP(for window) . This is a nice database tool and very easy to handle and easy linked with PHP for various database function
I recently developed something similar to what you are talking about and here is what I would suggest you to go for.
Use SQL server to manage the data on your desktop and create a web-service in .Net on Visual Studio.
(Note that as others have already mentioned, it really does not matter what is the database you are using in your server end, because eventually the data is going to come to the Android application from the server in form of either xml or json in the web-service., regardless of what database you are using. So it is totally your wish which database you want to use.)
Then connect to the web-service in your application and set/get data from the remote Database, using SOAP.
Link on how to make a web-service in .NET (does not include the implementation in Android).
Links on how to connect your service with Android : this, this and this.
I realize that Google App Engine (GAE) is very powerful and I would like to determine the proper way to create the database schema (outside of Android) and start populating the database (once my Android app is deployed). Then I would like to query the database (outside of Android). I was hoping that this would be a 10-20 line exercise but it is turning into a much harder task that I anticipated.
Out of Band Steps
Create Database via command line using proper GAE authorization.
Query Database via command line using proper GAE authorization.
I want to reiterate that I don't want to write Java code to create or query the database. I am more interested in using SQL or a SQL-like language directly vs. using Java.
Android Steps
Insert rows into the database using proper GAE authorization, encryption, etc.
Here are two ways to issue SQL statements to your Cloud SQL instance:
https://developers.google.com/cloud-sql/docs/commandline
https://developers.google.com/cloud-sql/docs/sql_prompt
As for inserting rows into the database from Android, you'll need to write a GAE app to act as a proxy. The app can then expose a REST API or whatever API you want.
I realise this is an old post but for people finding this via search, the link below is relevant and includes a sample android code:
https://developers.google.com/appengine/docs/java/endpoints/consume_android
Also, the Google Eclipse pluging also supports creating an App Engine Android project, see:
https://developers.google.com/eclipse/docs/endpoints-androidconnected-gae
In my project, I have to connect an Android mobile phone to a remote MySQL database server, to insert data to the database and get the data back later.
However, it seems that Android OS only supports the SQLLite database that works LOCALLY inside the phone.
Does anyone know how to connect an Android phone to a remote MySQL (or MSSQL, or Oracle) database server ?
Thank you!
You will have to access the database using some sort of Remote Method Invocation (RMI).
My personal recommendation is to create a RESTful HTTP interface to your MySQL database on the server. This may be a bit more work, but is preferred for its ease of use and compatibility with any system (that can make an HTTP request that is).
Essentially, you should create HTTP endpoints to Create, Read, Update, Delete (CRUD) data from your MySQL database on your server. Your Android client would then make calls to these HTTP endpoints to perform the corresponding CRUD operations. Of course you do not need to do the typical CRUD operations, you can make your endpoints interact with the database however you wish.
Like I said, a big advantage to this is how extensible it is. You can create another client, on another system, in another language, and all you need to do is make the proper HTTP call.
try using Jdbc... for more read this http://developer.android.com/reference/java/sql/package-summary.html