I keep getting a file not found error, even though it exists at /mnt/sdcard/folder/Samples.zip. I downloaded the file there, so there are “write” permissions, but it just doesn’t want to unzip! Why is this?
ZipInputStream in = null;
try {
final String zipPath = "/folder/Samples.zip";
in = new ZipInputStream(getAssets().open(
Environment.getExternalStorageDirectory() + zipPath));
for (ZipEntry entry = in.getNextEntry(); entry != null; entry = in
.getNextEntry()) {
}
} catch (IOException e) {
System.out.println("file error of some kind" + e);
} finally {
try {
if (in != null) {
in.close();
}
} catch (IOException ignored) {
}
in = null;
}
Try replacing
with
Context.getAssets() returns an AssetManager, which is normally used to access files in your project’s /assets folder, not external files.
(Also, if you have your phone connected to your PC with a USB cable, it might not be allowing access to your SD Card. Try unplugging from USB when you run your app. Might just be an issue with my phone, though.)