in a kotlin function i did something like this ``...
# android
p
in a kotlin function i did something like this
Copy code
fun f(){

	val reportAbout = binding.createReportReportAboutTextView.text.toString()
        val reportDesc = binding.createReportEditText.text.toString()
        var imageURL = ""
        var videoURL = ""
        val timestamp = System.currentTimeMillis()/1000

        var filename = UUID.randomUUID().toString()

	imgref = FirebaseStorage.getInstance().getReference("/report_videos/$filename")
        if(selectedVideoURI!=null)
            imgref.putFile(selectedVideoURI!!).addOnSuccessListener {
                imgref.downloadUrl.addOnSuccessListener {
                    videoURL = it.toString()
                    ref.setValue(ReportModel(ref.key.toString(),reportAbout ,reportDesc,imageURL,videoURL,timestamp))
                }
            }

	// LOG.d("TAG","$videoURL")
}
whenever i print videoURL in logcat, it shows empty, but inside imgref.putFile() function it has some value. does the imgref.putFile() funciton executes last in order? how can i execute the commented line in last by order.
d
Your Firebase logic is async. You can add your logging statement after you reassign the videoURL value and it will show correctly.