Andrew
Andrew

Reputation: 91

How to create directory in an Android project that will be located in the files dir during installation of an app?

My goal is to have /data/data/pkgname/files/mydir/myfile.txt

By default there are only cache and code_cache

I know that I can getFilesDir() in code and create necessary directories and files.

However is it possible to simply create necessary dirs with files in the project folder before building? (I tried creating this dir in root of the project, in main, src, nothing seems to work)

Thank you in advance!

Upvotes: 0

Views: 168

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006554

However is it possible to simply create necessary dirs with files in the project folder before building?

No, sorry.

You can put a directory tree with files in assets/. However, those do not turn into files on the filesystem of the device automatically. You can access them via AssetManager, either to just use directly or to serve as the basis for copying that tree to files in getFilesDir().

Upvotes: 1

Related Questions