Last active
August 29, 2015 14:25
-
-
Save t-kashima/36afac6844842878633d to your computer and use it in GitHub Desktop.
Firebase for Java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Firebase.setAndroidContext(this); | |
Firebase rootRef = new Firebase("https://firebase-app.firebaseio.com"); | |
Map<String, String> member = new HashMap<String, String>(); | |
member.put("name", "Google"); | |
Firebase data = rootRef.push(); | |
data.setValue(member); | |
rootRef.child(data.getKey()).child("name").addValueEventListener(new ValueEventListener() { | |
@Override | |
public void onDataChange(DataSnapshot snapshot) { | |
Log.d("Firebase", snapshot.getValue().toString()); | |
} | |
@Override | |
public void onCancelled(FirebaseError firebaseError) { | |
System.out.println("The read failed: " + firebaseError.getMessage()); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment