我试图通过身份验证在我的firebase数据库中保存数据。我有这个代码,我正在验证:
public void actualizardatos(){
String FIREBASE_URL = "https://admob-app-id-5989251146.firebaseio.com/";
Firebase.setAndroidContext(SignInActivityGoogle.this);
database=new Firebase(FIREBASE_URL);
String user=acct.getId();
Firebase firebase;
assert user != null;
firebase = database.child("users").child(user);
firebase.setValue(user);
}
但是当我尝试使用actualizardatos()保存数据时,他们告诉我W / RepoOperation:/ users / xxxxx处的setValue失败:FirebaseError:Permission denied
actualizardatos():
{
"rules": {
".read": "auth !== null",
".write": "auth != null",
"users": {
".read": "auth !== null",
".write": "auth != null",
"$user_id":{
".read": "auth !== null",
".write": "auth != null",
"coins":{
".read": "auth !== null",
".write": "auth != null"
},
"level":{
".read": "auth !== null",
".write": "auth != null"
},
"listitems":{
".read": "auth !== null",
".write": "auth != null"
},
"lastsave":{
".read": "auth !== null",
".write": "auth != null"
}
}
}
}
我的规则:
if ( /* the condition */ ) {
// Yes, all characters of the string are English lowercase letters or dash or underline
} else {
// No, there is at least one unexpected character
}
编辑:问题解决了,我正在混合代码。我的问题是,在指南中,Google会更改语言并更改名称,这会让我感到困惑,我会寻找如何处理并混合代码。
示例:在本指南中,Google解释了如何在入门指南中登录数据库,我们可以看到最终变量DatabaseReference myRef,但在保存数据中,用西班牙语,我有一个名为mDatabase的变量,没有类,是相同的变量,但名称不同,我混淆并寻求其他代码的帮助。