use of android.content.res.AssetManager in project BetterBatteryStats by asksven.
the class SystemAppInstaller method copyAsset.
private static void copyAsset(Context ctx, String assetName, String targetPath) {
AssetManager assetManager = ctx.getAssets();
String[] files = null;
try {
files = assetManager.list("");
} catch (IOException e) {
Log.e("tag", e.getMessage());
}
for (String filename : files) {
if (filename.equals(assetName)) {
InputStream in = null;
OutputStream out = null;
try {
in = assetManager.open(filename);
String strOutFile = targetPath + "/" + filename;
out = new FileOutputStream(strOutFile);
copyFile(in, out);
in.close();
in = null;
out.flush();
out.close();
out = null;
} catch (Exception e) {
Log.e(TAG, "An error occured while reading " + filename);
}
}
}
}
use of android.content.res.AssetManager in project KeePassDX by Kunzisoft.
the class Kdb3 method testKeyfile.
private void testKeyfile(String dbAsset, String keyAsset, String password) throws Exception {
Context ctx = getContext();
File sdcard = Environment.getExternalStorageDirectory();
String keyPath = sdcard.getAbsolutePath() + "/key";
TestUtil.extractKey(ctx, keyAsset, keyPath);
AssetManager am = ctx.getAssets();
InputStream is = am.open(dbAsset, AssetManager.ACCESS_STREAMING);
ImporterV3 importer = new ImporterV3();
importer.openDatabase(is, password, TestUtil.getKeyFileInputStream(ctx, keyPath));
is.close();
}
use of android.content.res.AssetManager in project KeePassDX by Kunzisoft.
the class Kdb3Twofish method testReadTwofish.
public void testReadTwofish() throws Exception {
Context ctx = getContext();
AssetManager am = ctx.getAssets();
InputStream is = am.open("twofish.kdb", AssetManager.ACCESS_STREAMING);
ImporterV3 importer = new ImporterV3();
PwDatabaseV3 db = importer.openDatabase(is, "12345", null);
assertTrue(db.algorithm == PwEncryptionAlgorithm.Twofish);
is.close();
}
use of android.content.res.AssetManager in project KeePassDX by Kunzisoft.
the class Kdb4 method testComposite.
public void testComposite() throws IOException, InvalidDBException {
Context ctx = getContext();
AssetManager am = ctx.getAssets();
InputStream is = am.open("keyfile.kdbx", AssetManager.ACCESS_STREAMING);
ImporterV4 importer = new ImporterV4();
importer.openDatabase(is, "12345", TestUtil.getKeyFileInputStream(ctx, TestUtil.getSdPath("key")));
is.close();
}
use of android.content.res.AssetManager in project KeePassDX by Kunzisoft.
the class Kdb4 method testCompositeBinary.
public void testCompositeBinary() throws IOException, InvalidDBException {
Context ctx = getContext();
AssetManager am = ctx.getAssets();
InputStream is = am.open("keyfile-binary.kdbx", AssetManager.ACCESS_STREAMING);
ImporterV4 importer = new ImporterV4();
importer.openDatabase(is, "12345", TestUtil.getKeyFileInputStream(ctx, TestUtil.getSdPath("key-binary")));
is.close();
}
Aggregations