Tag firebase-realtime-database

[Solved] How can i make the app work offline with Firebase database

Simply activate offline persistens as specified in the official documentation: Firebase applications work even if your app temporarily loses its network connection. You can enable disk persistence with just one line of code: FirebaseDatabase.getInstance().setPersistenceEnabled(true); solved How can i make the…

[Solved] i want to retrieve current logged user data from firestore but this show error [duplicate]

Change your onCreate method code to : protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_my_account); email = (TextView)findViewById(R.id.email_txt); mAuth = FirebaseAuth.getInstance(); UserId = mAuth.getCurrentUser().getUid(); passwordtxt = (TextView)findViewById(R.id.pass_txt); mFirestore = FirebaseFirestore.getInstance(); mFirestore.collection(“Hospitals”).document(UserId).get().addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() { @Override public void onSuccess(DocumentSnapshot documentSnapshot) { String user_name…

[Solved] How to resolve method getDownloadUrl() [duplicate]

Try this: filepath.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() { @Override public void onSuccess(Uri uri) { //Do what you need to do with the URL } }).addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception exception) { // Handle any errors } }); 0 solved How…

[Solved] How to get firebase generated unique id [closed]

Check your MyFirebaseInstanceIDService class there will be a method onTokenRefresh(). You will get refreshedToken in this method like below: public void onTokenRefresh() { // Get updated InstanceID token. String refreshedToken = FirebaseInstanceId.getInstance().getToken(); // TODO: Implement this method to send any…

[Solved] how can i get the count of key , value pair in firebase? [closed]

you can count children this way. databaseRef.addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { for (DataSnapshot snap: dataSnapshot.getChildren()) { Log.e(snap.getKey(),snap.getChildrenCount() + “”); } } @Override public void onCancelled(DatabaseError databaseError) { } }); 1 solved how can i get the…

[Solved] save text message in Shared Preferences [duplicate]

I don’t see why you would like to do that, but sure. If saving to SharedPrefs is all you want, it’s quite straight forward SharedPreferences sharedPref = getPreferences(Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPref.edit(); editor.putString(“yourMessageKey”, message); editor.commit(); And of course, to read…

[Solved] To store gps location in firebase real time database

You can send the location to Firebase by using the Firebase Database and DatabaseReference classes. First you have to make sure that you have these SDK’s in build.gradle: implementation ‘com.google.firebase:firebase-storage:16.0.4’ implementation ‘com.google.firebase:firebase-database:16.0.4’ Also, make sure that you have set up…

[Solved] Firebase – How to order items?

You must must use orderedByChild by the key of the date you’d like to order the children by. You can then observe the Value or ChildAdded event type of this query to retrieve the children in ascending order of date.…

[Solved] How to get a specific given in Firebase [closed]

First of all initiate the database instance FirebaseDatabase firebaseDatabase = FirebaseDatabase.getInstance(); get the reference of your DB where you want to perform the operation DatabaseReference dbRef = firebaseDatabase.getReference(NAME_OF_DATABASE); then use this to get all the user with the name equal…

[Solved] Retriving data from Firebase in Arraylist in Android [closed]

Assuming you have a model class for your electrician object named Electrician, to get a list of electrician objects, please use the following code: DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference(); DatabaseReference electricianRef = rootRef.child(“Employee”).child(“Electrician”); ValueEventListener valueEventListener = new ValueEventListener() { @Override public…

[Solved] How to Sort Firebase data by date stored as Value

you should store the data in miliseconds, is not that hard, and then you can bring the data and parse it in Date , look at this snippet try{ HttpClient httpclient = new DefaultHttpClient(); HttpResponse response = httpclient.execute(new HttpGet(“”)); StatusLine…