use of android.content.res.AssetManager in project KeePassDX by Kunzisoft.
the class Kdb4 method testSaving.
private void testSaving(String inputFile, String password, String outputFile) throws IOException, InvalidDBException, PwDbOutputException {
Context ctx = getContext();
AssetManager am = ctx.getAssets();
InputStream is = am.open(inputFile, AssetManager.ACCESS_STREAMING);
ImporterV4 importer = new ImporterV4();
PwDatabaseV4 db = importer.openDatabase(is, password, null);
is.close();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PwDbV4Output output = (PwDbV4Output) PwDbOutput.getInstance(db, bos);
output.output();
byte[] data = bos.toByteArray();
FileOutputStream fos = new FileOutputStream(TestUtil.getSdPath(outputFile), false);
InputStream bis = new ByteArrayInputStream(data);
bis = new CopyInputStream(bis, fos);
importer = new ImporterV4();
db = importer.openDatabase(bis, password, null);
bis.close();
fos.close();
}
use of android.content.res.AssetManager in project KeePassDX by Kunzisoft.
the class Kdb4 method testKeyfile.
public void testKeyfile() throws IOException, InvalidDBException {
Context ctx = getContext();
AssetManager am = ctx.getAssets();
InputStream is = am.open("key-only.kdbx", AssetManager.ACCESS_STREAMING);
ImporterV4 importer = new ImporterV4();
importer.openDatabase(is, "", TestUtil.getKeyFileInputStream(ctx, TestUtil.getSdPath("key")));
is.close();
}
use of android.content.res.AssetManager in project BaseProject by fly803.
the class AppImageMgr method getImageFromAssetsFile.
/**
* 从Assets中读取图片
* @param filepath 相对路径
* @return Bitmap
*/
public static Bitmap getImageFromAssetsFile(String filepath, Context context) {
Bitmap image = null;
InputStream is = null;
AssetManager am = context.getResources().getAssets();
try {
is = am.open(filepath);
image = BitmapFactory.decodeStream(is);
is.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (is != null)
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return image;
}
use of android.content.res.AssetManager in project VirtualXposed by android-hacker.
the class VirtualCore method getResources.
public Resources getResources(String pkg) throws Resources.NotFoundException {
InstalledAppInfo installedAppInfo = getInstalledAppInfo(pkg, 0);
if (installedAppInfo != null) {
AssetManager assets = mirror.android.content.res.AssetManager.ctor.newInstance();
mirror.android.content.res.AssetManager.addAssetPath.call(assets, installedAppInfo.apkPath);
Resources hostRes = context.getResources();
return new Resources(assets, hostRes.getDisplayMetrics(), hostRes.getConfiguration());
}
throw new Resources.NotFoundException(pkg);
}
use of android.content.res.AssetManager in project browser by scoute-dich.
the class Cookie method loadHosts.
private static void loadHosts(final Context context) {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
AssetManager manager = context.getAssets();
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(manager.open(FILE)));
String line;
while ((line = reader.readLine()) != null) {
hostsCookie.add(line.toLowerCase(locale));
}
} catch (IOException i) {
Log.w("Browser", "Error loading hosts");
}
}
});
thread.start();
}
Aggregations