Last active
January 7, 2016 09:01
-
-
Save amsanjeev/16499e7c5edbdab1d313 to your computer and use it in GitHub Desktop.
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
/* | |
* Function to pretty print data stored in a firebase DB on android device . | |
* Requires Gson library | |
*/ | |
public void debugPrintRef(final Firebase ref){ | |
ref.addListenerForSingleValueEvent(new ValueEventListener() { | |
@Override | |
public void onDataChange(DataSnapshot dataSnapshot) { | |
Gson gson = new GsonBuilder().setPrettyPrinting().create(); | |
String json = gson.toJson(dataSnapshot.getValue()); | |
Logger.i(json); | |
} | |
@Override | |
public void onCancelled(FirebaseError firebaseError) { | |
Logger.e("The read failed: " + firebaseError.getMessage()); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment