Syncing app data to Google Account

2020-02-09 03:52发布

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?

2条回答
做自己的国王
2楼-- · 2020-02-09 04:06

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.

查看更多
倾城 Initia
3楼-- · 2020-02-09 04:17

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.

查看更多
登录 后发表回答