CacheFileProvider

Introduction: Minimal cache file provider
More: Author   ReportBugs   
Tags:

CacheFileProvider Release

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)

  1. add jitpack to your project's build.gradle:
repositories {
    maven { url "https://jitpack.io" }
}
  1. add the compile statement to your module's build.gradle:
dependencies {
    compile 'com.github.MFlisar:CacheFileProvider:0.1'
}

Usage - General

1) 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...
// ....

2) 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);
Support Me
Apps
About Me
Google+: Trinea trinea
GitHub: Trinea