Android Google Drive Api Query App Folder By Filename

val appFolderTask = driveResourceClient.appFolderappFolderTask.continueWithTask { task ->    val parent = task.result    val query = Query.Builder()            .addFilter(Filters.eq(SearchableField.TITLE, "backup-latest.db"))            .build()    driveResourceClient.queryChildren(parent, query)}.addOnSuccessListener { meta ->    if (meta.count > 0) {        val fileMeta = meta.get(0)    }    else {    }}.continueWithTask { task ->    val meta = task.result    if (meta.count == 0)   {        return@continueWithTask null    }    val fileMeta = meta.get(0)    val file = fileMeta.driveId.asDriveFile()    driveResourceClient.openFile(file, DriveFile.MODE_READ_ONLY)}.addOnSuccessListener { driveContents ->    val tempInputStream = driveContents.inputStream    val inputStream = tempInputStream.copyToByteArrayStream()    val outputStream = ByteArrayOutputStream()    inputStream.use { input ->        outputStream.use { output ->            input.copyTo(output)        }    }    val restoreData = String(outputStream.toByteArray(), Charsets.UTF_8)    // use this to free resources?    driveResourceClient.discardContents(driveContents)}

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.