Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions src/tasks/AndroidAppBuilder/Templates/MonoRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,33 +146,34 @@ public void onDestroy() {

static void unzipAssets(Context context, String toPath, String zipName) {
AssetManager assetManager = context.getAssets();
try {
InputStream inputStream = assetManager.open(zipName);
ZipInputStream zipInputStream = new ZipInputStream(new BufferedInputStream(inputStream));
try (InputStream inputStream = assetManager.open(zipName);
ZipInputStream zipInputStream = new ZipInputStream(new BufferedInputStream(inputStream))) {

ZipEntry zipEntry;
byte[] buffer = new byte[4096];
while ((zipEntry = zipInputStream.getNextEntry()) != null) {
String fileOrDirectory = zipEntry.getName();
Uri.Builder builder = new Uri.Builder();
builder.scheme("file");
builder.appendPath(toPath);
builder.appendPath(fileOrDirectory);
String fullToPath = builder.build().getPath();
File file = new File(toPath, fileOrDirectory);
File parent = new File(file.getParent());

if (zipEntry.isDirectory()) {
File directory = new File(fullToPath);
directory.mkdirs();
file.mkdirs();
continue;
}
else if (!parent.exists()) {
parent.mkdirs();
}

String fullToPath = file.getAbsolutePath();
Log.i("DOTNET", "Extracting asset to " + fullToPath);

int count = 0;
FileOutputStream fileOutputStream = new FileOutputStream(fullToPath);
while ((count = zipInputStream.read(buffer)) != -1) {
fileOutputStream.write(buffer, 0, count);
}
fileOutputStream.close();
zipInputStream.closeEntry();
}
zipInputStream.close();
Comment thread
steveisok marked this conversation as resolved.
} catch (IOException e) {
Log.e("DOTNET", e.getLocalizedMessage());
}
Expand Down