Computer scienceMobileAndroidPersistence

Internal, external, scoped storage

Media mounted

Report a typo

How would you complete the method call to verify if the external storage is available and writable prior to saving data?

fun writeToFile(context: Context, filename: String, data: String) {
    if (_______________ == Environment.MEDIA_MOUNTED) {
        val file = File(context.getExternalFilesDir(null), filename)
        FileOutputStream(file).use {
            it.write(data.toByteArray())
        }
    }
}
Enter a short text

Create a free account to access the full topic