I am fetching all the images from gallery and showing it in my android app.
Initialised in onCreate: supportLoaderManager.initLoader(IMAGE_LOADER_ID, null, this)
1st Problem:
In the above initialisation, supportLoaderManager is deprecated now. So what is the alternative?
Secondly, I am using below code to fetch the images:
override fun onCreateLoader(id: Int, args: Bundle?): Loader<Cursor> {
val uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI
val projection =
arrayOf(MediaStore.MediaColumns.DATA, MediaStore.Images.Media.BUCKET_DISPLAY_NAME)
val selection: String? = null //Selection criteria
val selectionArgs = arrayOf<String>() //Selection criteria
val sortOrder: String? = MediaStore.Images.Media.DEFAULT_SORT_ORDER
return CursorLoader(
applicationContext,
uri,
projection,
selection,
selectionArgs,
sortOrder
)
}
Here the images are coming in random order. So can anyone help me in sorting the images?