CacheFileProvider
![]()
What is it / What does it do?
This is a minimal library with a few lines of code and without dependencies that offers a simple cache file provider (simple read only access for sharing files with other apps).
Gradle (via JitPack.io)
- add jitpack to your project's
build.gradle
:
repositories {
maven { url "https://jitpack.io" }
}
- add the compile statement to your module's
build.gradle
:
dependencies {
compile 'com.github.MFlisar:CacheFileProvider:0.2'
}
Usage - General
- Simply create a file in your apps cache directory
File file = new File(getCacheDir() + File.separator + "testfile.txt");
// make sure something is written to this file...
// ....
- Simply create a
Uri
for the file in your cache directory and share it to another app and it will work
Uri shareableUri = CachedFileProvider.getCacheFileUri(appContext, file.getName());
Other things
Get the content providers authority:
String authority = CachedFileProvider.getAuthority(appContext);