Skip to content

Instantly share code, notes, and snippets.

@sunwicked
Created December 8, 2021 16:12
Show Gist options
  • Save sunwicked/819e777af66ecb9c0ed7dc8b2b8258f8 to your computer and use it in GitHub Desktop.
Save sunwicked/819e777af66ecb9c0ed7dc8b2b8258f8 to your computer and use it in GitHub Desktop.
readFileDataFromAsset
fun readFileDataFromAsset(context: Context, fileName: String): String? {
val data: String? = null
try {
data = context.assets.open(fileName).bufferedReader().use { it.readText() }
} catch (ioException: IOException) {
ioException.printStackTrace()
return null
}
return data
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment