0
votes

Currently I stored data from my Android / Java app in SQLite on the device. I want to dump this delimited/structured data to a mysql insance on Google CloudSQL. I have a google cloud account, setup a DB and have the cloud back end all ready. I have plenty of DB experience but am weak on java, cloud, etc After months of seeking working examples (GAE?) I know about this link:

https://cloud.google.com/appengine/docs/java/cloud-sql/

But it's not complete.

Can someone just post a very simple app that successfully executes a simple insert from Android/Java into Google CloudSQL and include all the code needed to get the data to the CloudSQL instance?

If this is a duplicate question and the complete code sample is already on StackOverflow I will gladly read it. I have not found a complete example yet.

Thanks in advance.

1
The reason you may not find a lot of examples of this is that generally mobile apps do not connect directly to the database but instead connect to an API that talks to the database. In order to connect to the database from your mobile app, you would need to distribute the database credentials with your app effectively giving everyone free access to do anything they please with your database. Consider looking into Firebase as a backend for your mobile app or building your own API.Vadim
Thanks Vadim. That is helpful. Is Google Application Engine one of the APIs that ultimately accesses Google CloudSQL? Also I will check out Firebase.Frank Zappa
In terms of the easiest options, I would suggest looking at Firebase and App Engine. Firebase removes some of the complexity of setting up and running your own API. However, Firebase uses its own storage. If the data has to be in Cloud SQL, you could write an app engine application to handle requests from the mobile app and then read/write data to the Cloud SQL instance.Vadim
Thanks again. No the brand, google cloudSQL is not required. I am just looking for a database in the cloud where I may store output from my mobile app. Then I want to develop analytics against the data in the cloud. I seek the ability to 1) Push the data from the mobile app to a cloud db 2) on the cloud db execute some aggregate calculations across multiple mobile users and then 3) Push the aggregate calculations from the cloud db back to each mobile app. If you believe Firebase can support that. I ill look at Firebase. ThanksFrank Zappa

1 Answers

0
votes

Try using Firebase or Realm instead to facilitate data flow to your mobile App. Firebase is built on reactive programming model where data is saved in Friebase and automatically synced with client device. Realm goes a step ahead in having you abstract a true API call via its interface. And otherwise yes as others responded your mobile app HAS to actually call an API service and not CloudSQL directly