Skip to content

Instantly share code, notes, and snippets.

@AdoraNwodo
Last active August 4, 2021 06:27
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save AdoraNwodo/72e24b06ebb6526328e64ca8393e7c2e to your computer and use it in GitHub Desktop.
Save AdoraNwodo/72e24b06ebb6526328e64ca8393e7c2e to your computer and use it in GitHub Desktop.
private fun addUploadRecordToDb(uri: String){
val db = FirebaseFirestore.getInstance()
val data = HashMap<String, Any>()
data["imageUrl"] = uri
db.collection("posts")
.add(data)
.addOnSuccessListener { documentReference ->
Toast.makeText(this, "Saved to DB", Toast.LENGTH_LONG).show()
}
.addOnFailureListener { e ->
Toast.makeText(this, "Error saving to DB", Toast.LENGTH_LONG).show()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment