I want to connect to the Google Cloud SQL from my android app.
Is there a way to do this without the App Engine and Endpoints?
If this does not exist, please tell me the most painless way to solve this problem. I'm just in the future does not intend to use the App Engine, and therefore do not understand why waste time on it.
I have actually used Google Cloud SQL with App Engine + Endpoints (Java) so I can weigh in here a little.
You can create a helper class in App Engine and easily connect to Google Cloud SQL. Then, you can create endpoint methods that take in some parameters and inside the method access Cloud SQL and perform some operations securely.
This is highly advisable against interacting with your Cloud SQL database in the Android client app because that is a big security risk. If someone decompiles your app somehow, they now have full access to your database credentials.
If you have not a very large app you can use the above approach. But honestly, I would just the time to learn GAE Datastore and use that instead or Firebase. SQL can run into issues if your app gets big but maybe you aren't trying to build the next huge app so it will suffice. It all depends on you.
Hope that helps.
Related
I'm new in android studio I'd like to know how can I make requests to a server.
I wanted that in my Android App I sign up an account and my server stores all the users, something simple just to start. The next step that i want is like passing some strings or objects to other users.
How can I do that?
Is recommended to do my Server in Java/Python?
Thank you
I would suggest you first google your queries, since there are many such repositories on GitHub.
First Link when I searched Android CRUD was this
https://github.com/budasuyasa/simple-android-crud
As for Java or Python, all depends on your skill set, what I would recommend is using Spring boot for backend services but you can also use Flask to create Rest services in Python.
Have fun coding
We wanted to use cloud backend for storing Android app data.
Our backend RDBMS is famous MySQL server which comes with MySQL Connector/J (an Official MySQL Network JDBC Adapter which can connect to remote MySQL database).
Now the problem is we cannot use this MySQL Connector/J in Android as its not developed for android. So what we did is, we created a REST class with four rest methods /query, /insert, /update, /delete. All these methods takes JSON Object which is wrapping parameters of respective Android ContentProvider methods. /query rest method returns a tabular resultset data in JSON format.
Then we wrote Android ContentProvider which is acting as a proxy to call our above rest methods. ContentProvider.query() method calls /query rest method and converts the received resultset JSON into Cursor for returning it.
With this architecture our server code become generic without having any business logic. And our Android app is unaware of whether the data is coming from cloud server or local database. Practically all this is working fine.
So the question is how much secure this architecture is? from the hacking point of view. And what will be the impact on Android App performance? Please help us with your valuable comments/answers.
You not should connect directly from Android app to Database (MySQL), it will give you not good performance.
I recommend for you buid Webservice API which will connect to Database and fetch, hence from Android app connect and fetch data from Webservice.
I hope this helpful for you.
Anybody can decompile your code, find this service and if he breaks your service security he can do nasty things with your database. He can browse your database, steal data, corrup data .. Crackers are searching for SQL injection on web - and you are providing direct database access.
Do not do that. Create a service for each use case that will validate/escape parameters and then call prepared JDBC statement.
New to android programming and want to save basic student information in a database. What is the easiest and simplest way to store this data so it can be accessed by multiple devices remotely at any time? I know that android supports sqlite but this seems to be only locally on one device. Any ideas or suggestions?Eventually want to publish application on google play and want users to be able to see students names in their class for each class.
If you're not interested in setting up and maintaining a remote server, Firebase is fast, free to get started, and operates in realtime:
https://firebase.google.com/docs/database/
It seems you've answered your own question :) Place your relational database, such as MySQL, on a remote server. Create an API that performs CRUD operations on the database tables.
Then issue requests to the API in your android app: https://developer.android.com/training/volley/index.html
Yea you basically answered your own, I highly recommend using retrofit2 for android for http requests.You’ll use annotations to describe HTTP requests, URL parameter replacement and query parameter support is integrated by default. Additionally, it provides functionality for custom headers, multipart request body, file uploads and downloads, mocking responses and much more.
Here is great link to get started on your way to happy life:)
Ideally you would want to create your server to handle request and give responses, and android client for those request, if you are going the custom route you probably want a node.js server, or php server. You can even use socket.io to spice things up for real time communication, or maybe some notification system from firebase. Firebase is awesome, it handle all the aforementioned.
For the database portion if you decide not to use Firebase, please do not Raw SQLite you will have nightmares, use something like Realm it is NoSQL ,fast and easy to perform database transactions.
What is the best way to have a SQL database that can both be accessed by an android device via java code and by a web app via php code?
In my mind I imagined a MySQL database somewhere on the cloud that is accessed in all the normal ways by the web app using mysqli_connect and then somehow the same database calls are made in Java inside the android app.
But after some research it appears this may not be the way to do it. What is the way to do this correctly?
EDIT: It was suggested my question was too broad. What I want then is a database of some basic financial information which is stored on the cloud which is then able to be accessed via a web app written in the LAMP stack and via an android app (with java code).
It is a really simple problem but I am not sure what the best practice for such a problem is in android (I come from a web dev background)
The standard way to access a database for mobile application is different than a normal web page/application.
Mobile devices should never run queries in the database; What you do is create a web service that does all the queries in the database and then sends back HTTP responses in xml, JSON format to the mobile device for consumption.
At the same time you can create a web client that interacts with the web service the same way your mobile app does. This way if you get erroneous data you can debug the web service without having to recompile the code in the mobile app.
Do a Google search for restful web service
I first successfully connected via JDBC to a remote MySQL server with a Java program. That I understand how to do. My goal is do the same thing with an Android application and display data from a remote MySQL server.
Question 1 Can someone explain the process outline to do this via Android ? (I am new to Android and am a little stronger with Java, could use a little guidance).
Question 2 I found this tutorial on javatutorialpoint.com titled: Android MySQL Client but it wants me to use the SOAP API. Not sure why, if someone could explain.
Not asking for it to be done for me. I just want someone to outline the main steps in order to make it happen. Just the process that needs to occur is all I am asking.
Question #1:
I stumbled upon this link some time ago:
http://docs.oracle.com/cd/E17076_02/html/installation/build_android_jdbc.html
(Disclaimer: I haven't read the whole tutorial myself)
It tells you what's needed for getting the MySQL connector to work with Android.
Basically, from what I know, the standard MySQL connector for Java, doesn't work out of the box for Android. You'll need to build it on your own.
After building the connector, you can include it in your Android project, precisely the same way as you do in a normal Java project.
Your Question #2:
SOAP is a mere layer of abstraction, for not working directly on the database. If you use a layer like SOAP, you can swiftly change your database layer without affecting much of the communication from-and-to the Android app.
You can use the same methods in Android you used in Java (Android is written in Java, after all, and you are able to use the majority of its libraries in android). However, be careful with doing so.
It would probably be better from a security standpoint to set up a web service to communicate with the database, rather than you allowing your android app to communicate directly with it, which would actually require you to embed your mysql username and password in the app code. A SOAP or RESTful web service could enable your server to communicate with the DB and then serve the data from it to your app.
It's done the same as in Java (Android apps are build in Java unless you're using the NDK).
You don't need SOAP if you only want to get data from a remote DB.
See this question.