Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to retrieve Firebase data in a (non Android) Java app?

Is there a way to retrieve data from Firebase to a Java application ?

I have an Android application which stores the data in to a Firebase database and I need to read that data in a Java application. I searched over the Internet, but I have not found a clear answer.

//not the URL from browser, the one above the database

        FirebaseOptions options = new FirebaseOptions.Builder()
            .setDatabaseUrl("https://database-ff395.firebaseio.com/")
            .setServiceAccount(new 
      FileInputStream("C:/Users/Denisa/Desktop/database-2aab74679b79.json"))
            .build();
        FirebaseApp.initializeApp(options);

        DatabaseReference ref = FirebaseDatabase
                .getInstance()
                .getReference("restricted_access/secret_document");

//here I try to reference the database and put a value in it

            final FirebaseDatabase database = FirebaseDatabase.getInstance();
            DatabaseReference ref1 = database.getReferenceFromUrl("https://database-ff395.firebaseio.com/database-ff395");
            ref1.setValue("ooo");
like image 260
Denisa Corbu Avatar asked Jun 19 '16 09:06

Denisa Corbu


People also ask

Can Firebase be used with Java?

Firebase can be used for Android, iOS, Web, or Unity. In this tutorial, we perform Firebase services for Android. So, it is essential to have basic knowledge of Android Studio. A good understanding of basic JAVA and XML is required that allows us to understand the concept of Firebase better.

Can we use Firebase database without authentication?

Now, you are able to use Firebase Storage without using Firebase authentication.


1 Answers

Accessing the Firebase Database from a regular (non-Android) JVM is considered a server platform by the Firebase documentation. You can find all about it in the Firebase documentation for its server SDKs.

like image 94
Frank van Puffelen Avatar answered Oct 15 '22 23:10

Frank van Puffelen