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:
- Settings → Apps & notifications → All apps
- Select the target app
- Tap Storage
- Check if the Change button is available
- 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:
- Settings → About device → tap Build number repeatedly
- Developer options enabled
- Open Developer options
- Enable: Force allow apps on external
This may reveal the Change button in the app’s storage settings.


コメント