Skip to content

Instantly share code, notes, and snippets.

@d4rken
Created May 2, 2016 09:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save d4rken/aa1b65c480e16782adbf2a2c7ea2fda8 to your computer and use it in GitHub Desktop.
Save d4rken/aa1b65c480e16782adbf2a2c7ea2fda8 to your computer and use it in GitHub Desktop.
Unpack a file from assets.
Timber.tag(TAG).i("Copying new binary...");
AssetManager assets = getContext().getAssets();
InputStream in = assets.open(assetName);
FileOutputStream f;
f = getContext().openFileOutput(mBinaryConfig.getBaseBinaryName(), Context.MODE_PRIVATE);
byte[] buffer = new byte[1024];
int len1;
while ((len1 = in.read(buffer)) > 0) {
f.write(buffer, 0, len1);
}
f.close();
Timber.tag(TAG).i("binary has been successfully created.");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment