18

How exactly does one use the Google account sign in feature in Android Apps?

For example, is it possible to store application data such as tables, shared preferences etc., to a google account from an Android app, and what advantages does this offer over a normal account creation feature inside an app?

The reason I ask is that in the app I plan to develop, it will contain an sqlite database to store rss urls to a user, along with shared preferences and content providers. How would the login process differ between the custom login for the app vs the Google Account login process?

jbailie1991
  • 1,305
  • 2
  • 21
  • 42
  • 1
    Have you looked at the [Google Drive Android API docs](https://developers.google.com/drive/android/appfolder)? – Bryan Herbst Sep 17 '14 at 15:31
  • I haven't actually, Ill take a look at those now. But even still, what is the general practice when using a Google Account to sign into apps? Are there resources on this? – jbailie1991 Sep 17 '14 at 15:34
  • Support for storing and syncing in the app data folder will likely be removed from Drive in the future. Clients requiring app data storage are strongly encouraged to migrate to a non-Drive solution such as Cloud Firestore. – Duna Oct 04 '19 at 12:26
  • https://firebase.google.com/products/firestore - the only supported one Drive Api Sync is deprecated – Duna Oct 04 '19 at 12:29

2 Answers2

31

I recommend using the Google Drive Android API if you want to store data to the cloud.

To use those APIs, you will need to authenticate your users using this guide.

For example, is it possible to store application data such as tables, shared preferences etc., to a google account from an Android app

The Drive API lets you save any type of file to a hidden folder on the user's Google Drive account. You could save a database, a JSON file, or whatever else you want.

what advantages does this offer over a normal account creation feature inside an app?

Here are a few advantages to allowing your user to use a Google account to sign in to your app:

  1. Security- Google spends a lot of time and energy ensuring that Google accounts are secure. If you use Google accounts in your app, you don't need to spend time and energy making sure your custom solution is secure.

  2. Convenience- Assuming your users are running standard Android, they are guaranteed to have a Google account already. They don't need to create a new account and they don't need to remember another password.

  3. Access to Google APIs- If you are trying to sync to the cloud, you can use existing APIs from Google to sync data. You don't need to implement this yourself using your own servers.

If you are only doing local storage (you don't need to save to the cloud or sync between devices), then you don't need the Drive APIs, but you still get the other benefits of using a Google account.

Bryan Herbst
  • 66,602
  • 10
  • 133
  • 120
  • Is Google Drive available for all google accounts without the user requesting such feature? – rraallvv Feb 18 '17 at 15:54
  • @rraallv not necessarily. Some Google Apps administrators may choose to turn Drive off for their users – Bryan Herbst Feb 18 '17 at 18:13
  • Please check [this](http://stackoverflow.com/q/42317503/1436359), thanks for the quick reply. – rraallvv Feb 18 '17 at 18:19
  • Great answer, is the Google Drive API showing a Dialog box for uploading the file? Is there a way I can make this happen in the background without presenting the user with a dialog box every time? – Daniele Feb 12 '18 at 09:02
  • can i store chat images in their drive? – Dhaval Jotaniya Feb 12 '18 at 13:21
  • @DhavalJotaniya you can store any files you want in Drive. – Bryan Herbst Feb 12 '18 at 14:17
  • Ref: https://developers.google.com/drive/android/deprecation#accessing_app_data Support for storing and syncing in the app data folder will likely be removed from Drive in the future. Clients requiring app data storage are strongly encouraged to migrate to a non-Drive solution such as Cloud Firestore. – Satheesh Kumar Sep 08 '19 at 13:53
  • 1
    Support for storing and syncing in the app data folder will likely be removed from Drive in the future. Clients requiring app data storage are strongly encouraged to migrate to a non-Drive solution such as Cloud Firestore. – Duna Oct 04 '19 at 12:27
7

Unfortunately Storing app data is deprecated now. Here is a discussion about a way to replace it. In general Google recommends to use slutions like Cloud Firestore:

Accessing App Data
Support for storing and syncing in the app data folder will likely be removed from Drive in the future. Clients requiring app data storage are strongly encouraged to migrate to a non-Drive solution such as Cloud Firestore.

Alex P
  • 124
  • 1
  • 11