Files for miles: Where to store them all?
summary
Concrete API advice and tradeoffs for storing files on Android: use Context.getFilesDir / getCacheDir / getNoBackupFilesDir / getCodeCacheDir for internal app data, use Storage Access Framework (ACTION_OPEN_DOCUMENT / CREATE_DOCUMENT) for user-owned files, and use Direct Boot by migrating only needed data to device protected storage via createDeviceProtectedStorageContext, UserManager.isUserUnlocked and move methods. Use StorageManager.getAllocatableBytes and allocateBytes for large downloads, getCacheSizeBytes and cache behaviors for quotas, prefer content URIs, FileProvider, ParcelFileDescriptor.detachFd and Android.system.OS over raw file paths.
AI-written summary · about
chapters (10)
- 0:00Intro
- 0:25Internal storage
- 1:52External storage
- 4:14Device protected storage
- 9:07Cached data
- 10:54Code snippets
- 14:19Sharing content
- 15:19Native code
- 16:55Media
- 17:53Outro
related talks
12mEverything about storage on Android
26mWhats new with Data Storage?
42mEncrypting Files on Android
32mWhat’s new in shared storage
43mSecure Storage and Sharing of Large Files
12mBackup, Restore, Migrate
26mBe part of document-centric Android
37mWhy can't my app open that file? A deep dive into the Android app sandbox
