David PHAM-VAN

Save shared pdf in cache on Android

... ... @@ -6,6 +6,7 @@
- Improve native code
- Add Printing.info()
- Use PageTheme in example
- Save shared pdf in cache on Android
## 2.1.9
... ...
... ... @@ -155,9 +155,14 @@ public class PrintingJob extends PrintDocumentAdapter {
assert name != null;
try {
final File externalFilesDirectory =
context.getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS);
File shareFile = new File(externalFilesDirectory, name);
final File shareDirectory = new File(context.getCacheDir(), "share");
if (!shareDirectory.exists()) {
if (!shareDirectory.mkdirs()) {
throw new IOException("Unable to create cache directory");
}
}
File shareFile = new File(shareDirectory, name);
FileOutputStream stream = new FileOutputStream(shareFile);
stream.write(data);
... ...
<?xml version="1.0" encoding="utf-8"?>
<paths>
<external-path name="external_files" path="."/>
</paths>
\ No newline at end of file
<cache-path name="share" path="/share/"/>
</paths>
... ...