Last active
September 27, 2021 14:58
-
-
Save LongClipeus/c17abc291acb884da9aefeec6b5b9da9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import android.content.Context | |
import androidx.annotation.RawRes | |
import com.tech.melait.common.utils.ResourceUtils.readRawFile | |
import kotlinx.coroutines.Dispatchers | |
import kotlinx.coroutines.withContext | |
suspend fun readRawFile(context: Context, @RawRes res: Int) = withContext(Dispatchers.Default) { | |
context.resources.readRawFile(res) | |
} | |
fun Resources.readRawFile(@RawRes rawResId: Int): String { | |
return openRawResource(rawResId).bufferedReader().use { it.readText() } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment