Skip to content
Advertisement

how to create a folder and file in internal storage using kotlin

I’m trying to create a file and folder on my internal storage
in manifest i have

JavaScript

these permissions.

JavaScript

i got this

JavaScript

i tried so many other thing from javatpoint to official java and kotlin tutorials. but none worked

Advertisement

Answer

ok got it,not specifying proper path.

JavaScript

then to check this, navigate to

Android -> data -> com.your.pkg_name -> files ->

There will see files got created.

note:- we can use different paths

val path = this.externalCacheDir
Android -> data -> com.your.pkg_name -> cache ->

val path = this.externalMediaDirs.first()
Android -> media

val path = this.getExternalFilesDirs(null).first()
val path = Environment.getExternalStorageDirectory().getPath()

print and check what the path is.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement