Use content resolver openInputStream

pull/187/head
M66B 4 years ago
parent f9a4c92b51
commit df8ecb3882

@ -23,7 +23,6 @@ import android.Manifest;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.res.AssetFileDescriptor;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.text.Spanned; import android.text.Spanned;
@ -101,8 +100,7 @@ public class ActivityDSN extends ActivityBase {
Result result = new Result(); Result result = new Result();
ContentResolver resolver = context.getContentResolver(); ContentResolver resolver = context.getContentResolver();
AssetFileDescriptor descriptor = resolver.openTypedAssetFileDescriptor(uri, "*/*", null); try (InputStream is = resolver.openInputStream(uri)) {
try (InputStream is = descriptor.createInputStream()) {
ByteArrayOutputStream bos = new ByteArrayOutputStream(); ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] buffer = new byte[Helper.BUFFER_SIZE]; byte[] buffer = new byte[Helper.BUFFER_SIZE];
int length; int length;

@ -24,7 +24,6 @@ import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.res.AssetFileDescriptor;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.text.Spanned; import android.text.Spanned;
@ -158,8 +157,7 @@ public class ActivityEML extends ActivityBase {
Result result = new Result(); Result result = new Result();
ContentResolver resolver = context.getContentResolver(); ContentResolver resolver = context.getContentResolver();
AssetFileDescriptor descriptor = resolver.openTypedAssetFileDescriptor(uri, "*/*", null); try (InputStream is = resolver.openInputStream(uri)) {
try (InputStream is = descriptor.createInputStream()) {
Properties props = MessageHelper.getSessionProperties(); Properties props = MessageHelper.getSessionProperties();
Session isession = Session.getInstance(props, null); Session isession = Session.getInstance(props, null);
@ -406,8 +404,7 @@ public class ActivityEML extends ActivityBase {
throw new IllegalArgumentException(context.getString(R.string.title_no_folder)); throw new IllegalArgumentException(context.getString(R.string.title_no_folder));
ContentResolver resolver = context.getContentResolver(); ContentResolver resolver = context.getContentResolver();
AssetFileDescriptor descriptor = resolver.openTypedAssetFileDescriptor(uri, "*/*", null); try (InputStream is = resolver.openInputStream(uri)) {
try (InputStream is = descriptor.createInputStream()) {
Properties props = MessageHelper.getSessionProperties(); Properties props = MessageHelper.getSessionProperties();
Session isession = Session.getInstance(props, null); Session isession = Session.getInstance(props, null);

@ -32,7 +32,6 @@ import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.AssetFileDescriptor;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
@ -704,8 +703,7 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
StringBuilder data = new StringBuilder(); StringBuilder data = new StringBuilder();
Log.i("Reading URI=" + uri); Log.i("Reading URI=" + uri);
ContentResolver resolver = context.getContentResolver(); ContentResolver resolver = context.getContentResolver();
AssetFileDescriptor descriptor = resolver.openTypedAssetFileDescriptor(uri, "*/*", null); try (InputStream raw = new BufferedInputStream(resolver.openInputStream(uri))) {
try (InputStream raw = new BufferedInputStream(descriptor.createInputStream())) {
InputStream in; InputStream in;
if (TextUtils.isEmpty(password)) if (TextUtils.isEmpty(password))

@ -23,7 +23,6 @@ import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.AssetFileDescriptor;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.text.TextUtils; import android.text.TextUtils;
@ -386,8 +385,7 @@ public class FragmentRules extends FragmentBase {
Log.i("Reading URI=" + uri); Log.i("Reading URI=" + uri);
ContentResolver resolver = context.getContentResolver(); ContentResolver resolver = context.getContentResolver();
AssetFileDescriptor descriptor = resolver.openTypedAssetFileDescriptor(uri, "*/*", null); try (InputStream is = resolver.openInputStream(uri)) {
try (InputStream is = descriptor.createInputStream()) {
BufferedReader reader = new BufferedReader(new InputStreamReader(is)); BufferedReader reader = new BufferedReader(new InputStreamReader(is));
String line; String line;
while ((line = reader.readLine()) != null) while ((line = reader.readLine()) != null)

Loading…
Cancel
Save