Allow file paths when importing directly from filesystem

The import path directly from the file system may not
result in using a content:// or file:// Uri, but instead
a file system path. If this occurs, attempt to use a FileInputStream
to read the contents.
This commit is contained in:
Branden Archer
2018-01-19 22:56:22 -05:00
parent f1b2c0d93d
commit f1b0a26591

View File

@@ -380,13 +380,24 @@ public class ImportExportActivity extends AppCompatActivity
try
{
InputStream reader = getContentResolver().openInputStream(uri);
InputStream reader;
if(uri.getScheme() != null)
{
reader = getContentResolver().openInputStream(uri);
}
else
{
reader = new FileInputStream(new File(uri.toString()));
}
Log.e(TAG, "Starting file import with: " + uri.toString());
startImport(reader, uri);
}
catch (FileNotFoundException e)
catch(FileNotFoundException e)
{
Log.e(TAG, "Failed to import file: " + uri.toString(), e);
onImportComplete(false, uri);
}
}
}