yes, It is very much possible, using FileProvider, you can keep your files secure in your cache, and give access to your files temporarily to viewers. Here is a link that will help you implement.
The Android support library v4 contains a class called FileProvider, it’s a special subclass of ContentProvider. This class help in sharing of files associated with an app by creating a content:// uri instead of a file:/// uri .
A content URI allows you to grant read and write access using temporary access permissions. So you can provide temporary access to files in our cache directory without needing our app to have WRITE_EXTERNAL_STORAGE permission.
The first thing you should do is add a new content provider to your AndroidManifest file:
<manifest>
...
<application>
...
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/fileprovider" />
</provider>
...
</application>
</manifest>
A FileProvider can only generate a content URI for files in directories that you specify beforehand. To specify a directory, specify its storage area and path in XML (save the file as res/xml/fileprovider.xml).
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<cache-path name="image" path="image/"/>
</paths>
Now you can share your apps cache files to other apps. To share file you need to add some more line to you intent.
File cacheFile = new File(context.getCacheDir(), "image/yoo.jpg");
Uri uri = FileProvider.getUriForFile(context, "my.package.provider",
cacheFile);
Intent intent = ShareCompat.IntentBuilder.from(context)
.setType("image/jpg")
.setSubject(context.getString(R.string.share_subject))
.setStream(uri)
.setChooserTitle(R.string.share_title)
.createChooserIntent()
.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
context.startActivity(intent);
First of all you have to get reference to your cache file you want to share, in our case its cacheFile located inside cache directory + image folder.
Next you have to get this cache file’s uri which can be obtained using FileProvider.getUriForFile. Here you have to replace my.package with your app package name. Do not remove that .provider from the end.
In the end when you are creating intent then just add flags Intent.FLAG_GRANT_READ_URI_PERMISSION to your intent so that other app can read this uri.
Reference: https://medium.com/androidsrc/share-cache-files-with-other-android-apps-using-fileprovider-897fe5705e45