0
0
Android Kotlinmobile~5 mins

File access and storage in Android Kotlin - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the difference between internal and external storage in Android?
Internal storage is private to the app and not accessible by other apps. External storage is shared and can be accessed by other apps and the user. External storage may be removable like an SD card.
Click to reveal answer
beginner
How do you write a text file to internal storage in Kotlin?
Use openFileOutput(filename, Context.MODE_PRIVATE) to get a FileOutputStream, then write bytes or strings to it. This saves the file privately for your app.
Click to reveal answer
intermediate
What permission is required to write to external storage on Android 10 and below?
You need the WRITE_EXTERNAL_STORAGE permission declared in the manifest and requested at runtime for Android 6.0 to 10.
Click to reveal answer
intermediate
What is the recommended way to access shared media files on Android 11 and above?
Use the MediaStore API with scoped storage. Direct file path access is restricted, so apps should use content URIs and system APIs to read/write media.
Click to reveal answer
beginner
How can you check if external storage is available for read and write?
Check Environment.getExternalStorageState() and compare it to Environment.MEDIA_MOUNTED for read/write access.
Click to reveal answer
Which method writes a file to internal storage in Android Kotlin?
AgetExternalFilesDir()
BFileOutputStream(Environment.getExternalStorageDirectory())
CopenFileOutput(filename, Context.MODE_PRIVATE)
DMediaStore.insert()
What permission is needed to write files to external storage on Android 9?
AINTERNET
BREAD_CONTACTS
CACCESS_FINE_LOCATION
DWRITE_EXTERNAL_STORAGE
How do you check if external storage is writable?
AEnvironment.getExternalStorageState() == Environment.MEDIA_MOUNTED
BFile.canWrite()
CContext.checkSelfPermission()
DMediaStore.isWritable()
Which API should you use to access shared media files on Android 11+?
AFile API with direct paths
BMediaStore API
CopenFileOutput()
DSharedPreferences
Where are files saved when using openFileOutput()?
AApp's internal storage directory
BDownloads folder
CExternal storage root
DCache directory
Explain how to save and read a text file in internal storage using Kotlin in Android.
Think about how you open a file stream to write and read files privately inside your app.
You got /5 concepts.
    Describe the changes in Android storage permissions and access from Android 10 to Android 11.
    Focus on how Android limits file access for privacy and what APIs replace old methods.
    You got /4 concepts.