I am trying to migrate my Android app to Storage Access Framework in case they deprecate file level access to the user's device storage (as it seems).
My app has to unpack a zip file and the following code is intended to perform that operation:
private boolean unpackZip(String targetPath, String zipFilePathUri //zipFilePath)
{
InputStream inputStream;
ZipInputStream zInputStream;
try
{
inputStream =getContentResolver().openInputStream(Uri.parse(zipFilePathUri));
//here's the old code
//inputStream = new FileInputStream(zipFilePath);
//ZipFile zfile=new ZipFile(inputStream);
int maxEntries;
File mainfmd = new File(targetPath);
zInputStream = new ZipInputStream(new BufferedInputStream(inputStream));
ZipEntry zipEntry;
int entriesCounter=0;
while ((zipEntry = zInputStream.getNextEntry()) != null)
....
....
How it can be noticed there is a different implementation when SAF comes into place. I experienced very bad performance when using getContentResolver().openInputStream, indeed I see that the real unpacking starts after a long pause in the app functioning, while it was very quick before. Am I wrong at believing that?