Home > OS >  How do I make a query equalto with a long value?
How do I make a query equalto with a long value?

Time:10-26

I tried to make a query from real time database using equalTo().

database.getReference(verifiedProductsDb.dbPartVerifiedProducts).order By Child(verifiedProductsDb.barcode).equalTo(b.toLong()).get().addOnCompleteListener {

but android studio gives out:

None of the following functions can be called with the argument supplied.
equalTo(Boolean) defined in com.google.firebase.database.Query
equalTo(Double) defined in com.google.firebase.database.Query
equal To(String?) defined in com.google.firebase.database.Query

Despite the fact that using setValue, long values are written to the same database quite successfully and without problems.

enter image description here enter image description here

CodePudding user response:

The Realtime Database API on Android only has support for Double number types. The underlying wire protocol and database will interpret the long numbers correctly though, so you should be able to just do:

database.getReference("VerifiedProducts")
  .orderByChild("barcode")
  .equalTo(b.toLong().toDouble()) //            
  • Related