Checking if field data has changed, and not any field in child data

I can check to see if any data that is a child of my help has changed, but I can’t find a way to check if any field in this child has changed.

Here is some .child ("job") code not working, because the job is a field. It was just something I tried.

 Firebase ref = new Firebase(Config.FIREBASE_URL);

        //adding a value event listener so if data in database changes it does in textview also not needed at the minute
        ref.child("Driver").child("Driver2").child("job").addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot snapshot) {

                for (DataSnapshot postSnapshot : snapshot.getChildren()) {


                    Toast.makeText(ProfileActivity.this, "YEAAA ", Toast.LENGTH_SHORT).show();

                }

            }

            /************had to implement this method****************/
            @Override
            public void onCancelled(FirebaseError firebaseError) {
                System.out.println("The read failed: " + firebaseError.getMessage());

            }
        });

here is json from the database

  "Driver" : {
    "Driver1" : {
      "job" : "none",
      "lat" : 53.4013419,
      "lon" : -111.803055,
      "name" : "JOHNNY"
    },
    "Driver2" : {
      "job" : "job",
      "lat" : 53.4012956,
      "lon" : -6.4091191,
      "name" : "MICK"
    },
    "Driver3" : {
      "job" : "cccc",
      "lat" : 45.815399,
      "lon" : 15.966568,
      "name" : "Boris"
    }
  }

I want to check if the task field is changing, because the coordinate fields will constantly change.

+4
source share
1 answer

addValueEventListener() reference, for loop. DataSnapshot job child, job, : none. . , .

+7

Source: https://habr.com/ru/post/1674249/


All Articles