Skip to content

Instantly share code, notes, and snippets.

@rajaumair7890
rajaumair7890 / LocalFileStorageRepository.kt
Created December 14, 2023 14:03
LocalFileStorage CRUD for Android
class LocalFileStorageRepository(
private val context: Context
) {
suspend fun saveImageToInternalStorage(filename: String, bitmap: Bitmap): Boolean{
return withContext(Dispatchers.IO) {
return@withContext try {
val isExistingFile = context.filesDir.listFiles()?.firstOrNull {
it.canRead() && it.isFile && it.nameWithoutExtension == filename