【发布时间】:2016-06-17 15:52:08
【问题描述】:
我正在尝试将我的 SQLite 数据库迁移到 Firebase 数据库,而我之前从未使用过 NoSQL 数据库,所以我遇到了很多麻烦。
我希望每个用户都有自己的“数据库”,所以到目前为止我所做的就是用这个来保存数据:
FirebaseDatabase database = FirebaseDatabase.getInstance(FirebaseApp.getInstance());
DatabaseReference myRef = database.getReference(mAuth.getCurrentUser().getUid());
但问题是,如果我将用户身份验证为匿名以正确保存,当用户通过 Google 进行身份验证时,Uid 会发生变化。
那么我应该怎么做才能解决这个问题? 我已经阅读了Firebase page 的所有文档,但我不知道该怎么做
我使用 FirebaseUI 来管理登录:
Integer resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity());
if (resultCode == ConnectionResult.SUCCESS) {
// not signed in
startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setProviders(
AuthUI.EMAIL_PROVIDER,
AuthUI.GOOGLE_PROVIDER)
.setTheme(R.style.IndigoTheme)
.build(),
RC_SIGN_IN);
} else {
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(resultCode, getActivity(), 0);
if (dialog != null) {
//This dialog will help the user update to the latest GooglePlayServices
dialog.show();
}
}
谢谢
【问题讨论】:
-
这似乎是错误的工作站点,因为它适用于 2.x SDK,而您使用的是最新版本。您正在寻找documentation on upgrading an anonymous account
-
@FrankvanPuffelen 哦,谢谢!我刚读过它,但我正在使用 FirebaseUI 来管理登录,所以我真的不知道如何使用它,我正在编辑我的问题以显示我的登录代码
标签: android firebase firebase-realtime-database firebase-authentication