I'm trying to use Firebase Realtime database following Firebase's guide online but I can't get any updates on the database as my permission is being denied. I am not sure what I'm doing wrong. I've even set the rules to read and write to true.
The code inside onClickListener is below:
Button vDetails = (Button) v.findViewById(R.id.enter_vechile_details);
vDetails.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
DatabaseReference myRef = FirebaseDatabase.getInstance().getReference();
myRef.child("Customers").child("Drivers").setValue("Name").addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.d(TAG, "signUp: set customer name" + e);
e.printStackTrace();
}
});
getFragmentManager().beginTransaction().replace(R.id.fragment_container, new SignUpCustomerFragment()).commit();
}
});
This is inside a fragment and the button completes those statements first before it begins the transaction for the fragment replacement.
This is the rules in Firebase:
{
"rules": {
".read": true,
".write": true
}
}
As I am new to JSON, I've also tried with a comma at the end of ".write"
{
"rules": {
".read": true,
".write": true,
}
}
This is the stacktrace:
09-10 04:32:46.274 16594-16594/com.buildingstories.sabbib.xpose W/System.err: com.google.firebase.database.DatabaseException: Firebase Database error: Permission denied
09-10 04:32:46.274 16594-16594/com.buildingstories.sabbib.xpose W/System.err: at com.google.firebase.database.DatabaseError.toException(Unknown Source)
09-10 04:32:46.274 16594-16594/com.buildingstories.sabbib.xpose W/System.err: at com.google.android.gms.internal.zzall$1.onComplete(Unknown Source)
09-10 04:32:46.274 16594-16594/com.buildingstories.sabbib.xpose W/System.err: at com.google.android.gms.internal.zzahq$20.run(Unknown Source)
09-10 04:32:46.274 16594-16594/com.buildingstories.sabbib.xpose W/System.err: at android.os.Handler.handleCallback(Handler.java:739)
09-10 04:32:46.274 16594-16594/com.buildingstories.sabbib.xpose W/System.err: at android.os.Handler.dispatchMessage(Handler.java:95)
09-10 04:32:46.274 16594-16594/com.buildingstories.sabbib.xpose W/System.err: at android.os.Looper.loop(Looper.java:168)
09-10 04:32:46.274 16594-16594/com.buildingstories.sabbib.xpose W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5885)
09-10 04:32:46.274 16594-16594/com.buildingstories.sabbib.xpose W/System.err: at java.lang.reflect.Method.invoke(Native Method)
09-10 04:32:46.274 16594-16594/com.buildingstories.sabbib.xpose W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
09-10 04:32:46.274 16594-16594/com.buildingstories.sabbib.xpose W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
09-10 04:32:46.274 16594-16594/com.buildingstories.sabbib.xpose W/IInputConnectionWrapper: endBatchEdit on inactive InputConnection
09-10 04:32:46.274 16594-16594/com.buildingstories.sabbib.xpose W/IInputConnectionWrapper: getTextBeforeCursor on inactive InputConnection
09-10 04:32:46.276 16594-16594/com.buildingstories.sabbib.xpose W/IInputConnectionWrapper: getTextAfterCursor on inactive InputConnection
I've been at this all day and I have no idea what's wrong since I followed the Firebase guide.