I have recently been using Firebase to transfer data across networks but the Java program I wrote will not change the data values. I have a firebase app with a tree like this.
<MY_WEBSITE>
|=>telemetry
|=>direction : 0
|=>speed : 0
and the code I'm using to try and write is this.
public class telem {
public static void main(String[] args) {
Firebase direction;
direction = new Firebase("https://<MY_WEBSITE>.firebaseio.com/telemetry/direction");
direction.setValue(1);
}
}
I continued to try using both a thread.sleep and a real-time listener (separately) and the output that returned in the console said that the data change went through, however, when I checked in forge the data had not changed.
Here is the code I used:
//CREATE A FIREBASE
Firebase fb = new Firebase("https://<MY_WEBSITE>.firebaseio.com/telemetry/direction");
//SAVE DATA
fb.setValue("1");
//LISTEN FOR REALTIME CHANGES
while(true) {
fb.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot snap) {
System.out.println(snap.getKey() + " -> " + snap.getValue());
}
@Override
public void onCancelled(FirebaseError error) {
}
});
}
And here is the response it returned:
direction -> 1