Skip to content

Commit

Permalink
Unprefer external storage for OS below Android 11
Browse files Browse the repository at this point in the history
  • Loading branch information
nain-F49FF806 committed Dec 25, 2024
1 parent aa88f06 commit 5885860
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android {
defaultConfig {
minSdk = rootProject.extra["minSdkVersion"] as Int
targetSdk = rootProject.extra["targetSdkVersion"] as Int
versionCode = 1733570000
versionName = "2024.12.07"
versionCode = 1735153000
versionName = "2024.12.25"
applicationId = "alt.nainapps.aer"
vectorDrawables {
useSupportLibrary = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package alt.nainapps.aer.documents.home

import android.content.Context
import android.os.Build
import android.os.Environment
import android.preference.PreferenceManager.getDefaultSharedPreferences
import java.io.File
Expand Down Expand Up @@ -39,6 +40,12 @@ class HomeEnvironment private constructor(
}

private fun getSelectExternalFilesDir(context: Context): File? {
// Below Android 11 (API 30) we do not prefer external storage
// as privacy of external filedir is guaranteed from Android 11 only.
// https://developer.android.com/about/versions/11/privacy/storage#other-app-specific-dirs
if (Build.VERSION.SDK_INT < 30) {
return null
}
val externalFilesDirs = context.getExternalFilesDirs(null)
// The first few (in forward order) may be on primary storage,
// so we traverse in reverse order to find first available externalFilesDir
Expand Down

0 comments on commit 5885860

Please sign in to comment.