Byte Brad
Byte Brad

Reputation: 2357

FileProvider for dynamic files

I would like to use FileProvider to get access of MyFirstApplication files in MySecondApplication which are stored in Internal Directory. I have gone through the documents for FileProvider and examples.

My question is, the folders and files in InternalStorage name may change at each instance. So in manifest.xml while defining the <meta-data> tag in <provider> I cannot give xml file with static path and name. I would like to pick the files and folders dynamically at runtime. Is this possible? If so, how can I acheive this?

EDIT : Here is what exactly I needed. I have two application. First application will store all files in its internal storage. Later I want to upload all those files (basically .zip files) through the second application. So those files to be accessed by second application also I need the path of those files.

Upvotes: 1

Views: 1163

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007544

You have two choices:

  1. Point the <meta-data> at the root directories in which your files and directories will exist. IOW, point at the lowest level where the locations will not change. This may require some reorganization of the rest of your code to limit the scope of your file/directory manipulation to some specific area.

  2. Don't use FileProvider, but instead roll your own ContentProvider that supports the streaming API with the business rules that you wish to employ.

Upvotes: 2

Related Questions