Why Adoptable Storage Does Not Automatically Use the SD Card

Android Development

Even when Adoptable Storage is correctly configured, Android does not automatically store app data on the SD card. Calling context.getFilesDir() always returns the internal storage path, not the SD card.Android merges internal storage and SD card into a single virtual pool, but directory structures are not unified.

How Android Decides Where App Data Is Stored

Android chooses storage location per app, not per file API call.

✔ getFilesDir()

Always points to internal storage: /data/user/0/<package>/files

✔ System decides storage placement

Apps cannot force getFilesDir() to map to SD card.

How to Make the App Use SD Card Storage

Users must manually move the app to the SD card:

  1. Settings → Apps & notifications → All apps
  2. Select the target app
  3. Tap Storage
  4. Check if the Change button is available
  5. Select SD card

Once moved, the physical location behind getFilesDir() switches to the SD card.

「アプリをSDカードに移動させる必要があります。」 (PDFより引用)

Manifest Setting Required for SD Card Migration

Apps must explicitly allow external storage installation:

xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    android:installLocation="auto">
</manifest>

✔ auto or preferExternal

Without this, Android keeps the app in internal storage and SD migration is blocked.

Difference Between getFilesDir() and getExternalFilesDirs()

Android still distinguishes:

  • Strict internal storage
  • Extended external storage (including Adoptable SD)

✔ getFilesDir()

Always internal.

✔ getExternalFilesDirs(null)

Returns multiple paths, including SD card if Adoptable Storage is active.

Example:

java

File[] dirs = context.getExternalFilesDirs(null);
for (int i = 0; i < dirs.length; i++) {
    Log.d("STORAGE_CHECK", "Index " + i + ": " + dirs[i].getAbsolutePath());
}

If SD is adopted, index 1 or later will point to SD storage.

Force SD Usage via Developer Options

If the app cannot be moved:

  1. Settings → About device → tap Build number repeatedly
  2. Developer options enabled
  3. Open Developer options
  4. Enable: Force allow apps on external

This may reveal the Change button in the app’s storage settings.

コメント