简体   繁体   中英

Firebase Android setValue method not working

I'm using firebase and my problem is when I used setValue , then I check website, I don't find any changes.

This is my code

firebaseRoot = new Firebase("https://xxxx-xxxxx.firebaseio.com/devices");

        Firebase deviceChild = firebaseRoot.child("child");
        deviceChild.addValueEventListener(new ValueEventListener()
        {
            @Override
            public void onDataChange(com.firebase.client.DataSnapshot dataSnapshot)
            {
                Logger.i(LOG, "onDataChange");
            }

            @Override
            public void onCancelled(FirebaseError firebaseError)
            {
                Logger.i(LOG, "onCancelled");
            }
        });

        deviceChild.setValue("test", new Firebase.CompletionListener()
        {
            @Override
            public void onComplete(FirebaseError firebaseError, Firebase firebase)
            {
                Logger.i(LOG, "onComplete");
            }
        });

In log i keep getting

 E/FirebaseCrash: Error sending crash report: IOException while sending a crash report

It does enter the method onDataChange , does this mean it saved it? if yes, then why i can't see it in website?

Since i'm only testing, this is my rules for Database

{
  "rules": {
    ".read": true,
    ".write": true
  }
}

EDIT I've also tried the following code

FirebaseDatabase database = FirebaseDatabase.getInstance();
        DatabaseReference myRef = database.getReference(url);
        myRef.setValue("Hello, World!").addOnCompleteListener(new OnCompleteListener<Void>()
        {
            @Override
            public void onComplete(@NonNull Task<Void> task)
            {
                Logger.i(LOG, "onComplete");
            }
        }).addOnFailureListener(new OnFailureListener()
        {
            @Override
            public void onFailure(@NonNull Exception e)
            {
                Logger.i(LOG, "onCancelled");
            }
        });

Still doesn't work. can anyone tell me what is wrong?

Okay so the problem was that my tablet date, not sure why, was 2015 and I guess some Internet validation somewhere blocked me. The code is working though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM