How to use Gmail/Drive as a cloud database for building Android app?

Yes you can use Drive or Dropbox as the database for building Android application but not Gmail as Gmail doesn’t provide space to upload data.

But i don’t recommend you to go with Drive or Dropbox to use as a cloud database because they are not meant to be used as Database.

I have tried the same thing to provide configuration to my Android application and that configuration file is in the form of JSON uploaded on Dropbox. And whenever i need to configure my app on runtime i just need to call Dropbox API and from that API i can access files in my connected Dropbox account. From that account we can easily read the file and can work accordingly .

Using Drive or Dropbox will not serve same as a database but yes you can use them for small configuration or small level database. What you can do is you can create a text file, XML file or JSON file that contains all your content in the form of key value where key will serve as database column and value will serve column value. Or even you can upload db file which you need to parse in android app.

Now you need to connect Dropbox or Drive APIs with your android application using Gradle or jar file. Once you connect API you need to register you application on their developer’s page and from there you can get App secret and App Token.

In Dropbox or Drive APIs we have Login API, we have download API, we have upload API.

Firstly you need to use Login API to Login into your account where you have uploaded the database file. And after successful login you will get login token that can be used whenever you want to access file from your Dropbox or Drive account without login again and again. Its like Single Sign in. From next time you just need this token to directly access of files of your dropbox or drive account.

Now we need to call download API with our login token and file name and path of that file. By this way Dropbox API will download that file in your Android device. Next you need to open that file, read and parse that file. And work accordingly.

I hope this will help. But i recommend you don’t go with Drive or Dropdox if you are planning to create high end applications as that will slow down your application.

Be the first to comment

Leave a Reply

Your email address will not be published.