diff options
author | David-Development <david-dev@live.de> | 2021-05-13 15:17:50 +0300 |
---|---|---|
committer | David Luhmer <david-dev@live.de> | 2021-05-13 15:17:50 +0300 |
commit | adce89d60b91de70405c9b9b3fa6e16d900d3931 (patch) | |
tree | 199c05266bec459a4339ffdcee45bcc64eff77b1 /News-Android-App/src/main/java | |
parent | ea0fb9c9bc1e760e24719f0a9d4e544a26e50bdd (diff) |
Fix visiblity of opml files / use try-with-resources for export
Signed-off-by: David Luhmer <david-dev@live.de>
Diffstat (limited to 'News-Android-App/src/main/java')
-rw-r--r-- | News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewFeedActivity.java | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewFeedActivity.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewFeedActivity.java index 7f082b30..1383483b 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewFeedActivity.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewFeedActivity.java @@ -163,8 +163,7 @@ public class NewFeedActivity extends AppCompatActivity { private void openFilePicker() { startActivityForResult(new Intent(Intent.ACTION_GET_CONTENT) - .addCategory(Intent.CATEGORY_OPENABLE) - .setType("text/*"), REQUEST_CODE_OPML_IMPORT); + .addCategory(Intent.CATEGORY_OPENABLE).setType("*/*"), REQUEST_CODE_OPML_IMPORT); } public void exportOpml() { @@ -219,12 +218,12 @@ public class NewFeedActivity extends AppCompatActivity { case ContentResolver.SCHEME_CONTENT: case ContentResolver.SCHEME_FILE: new Thread(() -> { - try { - final File cacheFile = new File(getCacheDir().getAbsolutePath() + "/import.opml"); - final FileOutputStream outputStream = new FileOutputStream(cacheFile); - byte[] buffer = new byte[4096]; - final InputStream inputStream = getContentResolver().openInputStream(importUri); - + final File cacheFile = new File(getCacheDir().getAbsolutePath() + "/import.opml"); + byte[] buffer = new byte[4096]; + try ( + final InputStream inputStream = getContentResolver().openInputStream(importUri); + final FileOutputStream outputStream = new FileOutputStream(cacheFile) + ) { int count; while ((count = inputStream.read(buffer)) > 0) { outputStream.write(buffer, 0, count); |