Created
June 7, 2021 16:54
-
-
Save yogen-p/ecdd86059cc7d322e46c741096ba3d37 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun loadJSONFromAsset(context: Context, name: String): String { | |
var json = "" | |
try { | |
val inputStream = context.applicationContext.assets.open(name) | |
val size = inputStream.available() | |
val buffer = ByteArray(size) | |
inputStream.read(buffer) | |
inputStream.close() | |
json = String(buffer, Charsets.UTF_8) | |
} catch (ioException: IOException) { | |
Log.d(APP_DEBUG, ioException.toString()) | |
} | |
return json | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment