'Constantly refreshing RecycleView with Retrofit instance

I'm trying to update my recyclerview but i don't really know how to tacle the issue, i can already print my list of data, for that i juste send my list to my adapter but i'd like to refresh it every 5 second. Someone know a solution? Here's my fragment thanks.

class DlFragment (
        private val context: MainActivity
    ): Fragment(){

override fun onCreateView(
            inflater: LayoutInflater,
            container: ViewGroup?,
            savedInstanceState: Bundle?
         ): View? {

    val view = inflater?.inflate(R.layout.fragment_dl,container, false)

    getDlList()

    val comfirmButton= view.findViewById<Button>(R.id.input_post_dl_button)
    comfirmButton.setOnClickListener { postDl(view) }

    return view
}

private fun getDlList() {
    GlobalScope.launch(Dispatchers.Main) {
        try {
            val response = ApiClientQnap.apiServiceQnap.getQuery(0,0,"all","all",ApiClientQnap.sid)

            if (response.isSuccessful && response.body() != null) {
                val content = response.body()
                if (content != null) {
                    //println(content)
                    val dlRecyclerView = view?.findViewById<RecyclerView>(R.id.dl_list_recycle_view)
                    dlRecyclerView?.adapter = DlAdapter(context, content.data)
                }
            } else { println("Error Occurred: ${response.message()}") }
        } catch (e: Exception) {println("Error Occurred: ${e.message}") }
    }
}

}



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source