Skip to content

Commit

Permalink
fix: Fixed crash when externalFilesDir is not mounted
Browse files Browse the repository at this point in the history
  • Loading branch information
timschneeb committed May 23, 2023
1 parent cf6eb31 commit d5f6f94
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.preference.Preference.SummaryProvider
import me.timschneeberger.rootlessjamesdsp.R
import me.timschneeberger.rootlessjamesdsp.model.preset.Preset
import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.toast
import timber.log.Timber
import java.io.File
import java.io.InputStream

Expand Down Expand Up @@ -147,8 +148,11 @@ class FileLibraryPreference(context: Context, attrs: AttributeSet?) :
fun createFullPathCompat(context: Context, path: String): String {
return if(path.startsWith("/"))
path
else
context.getExternalFilesDir(null)!!.absolutePath + "/" + path
else {
val externalDir = context.getExternalFilesDir(null)
externalDir ?: Timber.e("getExternalFilesDir returned null")
externalDir?.let { it.absolutePath + "/" + path } ?: ""
}
}
fun createFullPathNullCompat(context: Context, path: String?): String? {
path ?: return null
Expand Down

0 comments on commit d5f6f94

Please sign in to comment.