Issue
private lateinit var cDatabaseRef: DatabaseReference
private fun addUserToDatabase (uid:String,custID:String,custName:String,custPostAddress:String,custPhoneNumber:String,email:String){
try{
cDatabaseRef = FirebaseDatabase.getInstance().getReference()
val newCustomer = Customer(custName,email,custID,custPostAddress,custPhoneNumber,uid)
cDatabaseRef.child("Customers").child(uid).setValue(newCustomer).addOnSuccessListener { Toast.makeText(this, "Success added", Toast.LENGTH_SHORT).show()
val intent = Intent(this, CustLoginActivity::class.java)
finish()
startActivity(intent)
}
} catch(e : Exception){
Toast.makeText(this, "Some error occurred", Toast.LENGTH_SHORT).show()
}
}
The problem is, the Success added does not appear and the Realtime Database of firebase does not add any data. I also addOnFailureListener and OnCanceledListener, but both do not detect the error. Although there is no error, the database does not add any new data
Solution
The problem is the URL of the real time database does not contain in the jason file which may cause by I include the jason file before I create a real-time database. The solution is below
cDatabaseRef = FirebaseDatabase.getInstance("AddingURL from firebase realtime database").getReference()
Answered By - student aaa
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.