These code examples were ranked by Codota’s semantic indexing as the best open source examples for Context getDir method.
public ModuleClassLoader(Object envContext) { if (!(envContext instanceof Context)) { throw new IllegalArgumentException(); } Context androidContext = (Context) envContext; defaultClassLoader = androidContext.getClassLoader(); PackageManager pkgMgr = androidContext.getPackageManager(); if (pkgMgr != null && pkgMgr.checkSignatures(androidContext.getPackageName(), packageName) >= 0) { String dexPath = null; try { dexPath = pkgMgr.getApplicationInfo(packageName, 0).sourceDir; } catch (NameNotFoundException e) {} if (dexPath != null) { String dexOutputDir = androidContext.getDir("dex", 0).getAbsolutePath(); internalClassLoader = new DexClassLoader(dexPath, dexOutputDir, null, androidContext.getClassLoader()); } }
super.applyWebSettings(view); WebSettings settings = view.getSettings(); settings.setDatabaseEnabled(true); Context context = view.getContext(); String databasePath = context.getDir("database", Context.MODE_PRIVATE).getPath(); settings.setDatabasePath(databasePath); } }
try{ //读取files目录下的config //fis = activity.openFileInput(APP_CONFIG); //读取app_config目录下的config File dirConf = mContext.getDir(APP_CONFIG, Context.MODE_PRIVATE); fis = new FileInputStream(dirConf.getPath() + File.separator + APP_CONFIG); props.load(fis); }catch(Exception e){ }finally{ try { fis.close(); } catch (Exception e) {} } return props; } private void setProps(Properties p) { FileOutputStream fos = null;
*/ static class MoSyncWebView extends CordovaWebView { public MoSyncWebView(Context context) { super(context); // Java script is enabled by default on iOS so let make // it so here too. // This might affect memory consumption / performance. this.getSettings().setJavaScriptEnabled(true); //use the default path for storage and database String databasePath = context.getDir("database", Context.MODE_PRIVATE).getPath(); this.getSettings().setDatabasePath(databasePath); // Enable support for WebView geolocation. this.getSettings().setGeolocationEnabled(true);
return mBaseContext.getResources(); } @Override public File getDir(String name, int mode) { return mBaseContext.getDir("mockcontext2_" + name, mode); } } /** {@link IsolatedContext} + getApplicationContext() */ private static class MyIsolatedContext extends IsolatedContext { private final Context mRealContext; public MyIsolatedContext(ContentResolver resolver, Context targetContext, Context realContext) { super(resolver, targetContext); mRealContext = realContext; } @Override
throws ClassNotFoundException { // This kind of reflection is expensive, so let's only do it // if we need to Class<?> klass = sClassMap.get(packageName); if (klass == null) { DexClassLoader classLoader = new DexClassLoader( sourceDir, "/data/local/tmp", null, ClassLoader.getSystemClassLoader()); klass = classLoader.loadClass(packageName + ".R$id"); sClassMap.put(packageName, klass); } return klass; } private static AccessibilityNodeInfo getNodeByAccessibilityIds( String windowString, String viewString) { int windowId = Integer.parseInt(windowString); int viewId = Integer.parseInt(viewString); int connectionId = sUiTestAutomationBridge.getConnectionId(); AccessibilityInteractionClient client = AccessibilityInteractionClient.getInstance();
try { final File optimizedDexOutputPath = getDir("outdex", Context.MODE_PRIVATE); // On charge le plugin DexClassLoader cl = new DexClassLoader( this.file.getAbsolutePath(), optimizedDexOutputPath.getAbsolutePath(), null, getClassLoader()); // On instancie la classe du plugin Class<?> libClass = cl.loadClass(this.classname); // PluginInterface lib = (PluginInterface) // libClass.newInstance(); // // lib.run(this.ctx, this.layout); } catch (Exception e) { e.printStackTrace(); } }
public static final int eAM_STATUS_USURP_FAILURE = 13; private AuthentecHelper(Context ctx) { try { AuthentecMobile = sAuthentecClassLoader.loadClass("com.authentec.amjni.AuthentecMobile"); TSM = sAuthentecClassLoader.loadClass("com.authentec.amjni.TSM"); Constructor ctor = AuthentecMobile.getDeclaredConstructors()[0]; am = ctor.newInstance(ctx); } catch (Exception ex) { ex.printStackTrace(); return; } } public int fingerprintUnlock(String sScreen, Context ctx) { int iResult = 0; try { if (! (Boolean) AuthentecMobile.getMethod("AM2ClientLibraryLoaded").invoke(am)) {
tmp.mkdirs(); } @Override public ClassLoader getClassLoader(URL url, ClassLoader parent) { return new DexClassLoader(url.getPath(), tmp.getAbsolutePath(), null, parent); } } /** * Implementation for the reference implementation. Nothing interesting to * see here. Please get along. */ static class RefImpl extends Support_ClassLoader { @Override public ClassLoader getClassLoader(URL url, ClassLoader parent) { return new URLClassLoader(new URL[] { url }, parent); } }
private EffectsInterface SelectImplementation() { EffectsInterface efi = null; String defaultLibPath = mActivity.getAssets() + "/Plugins/effectjava.jar"; File dexOutputDir = mActivity.getDir("dex", Context.MODE_PRIVATE); DexClassLoader dcl = new DexClassLoader(defaultLibPath, dexOutputDir.getAbsolutePath(), null, ClassLoader.getSystemClassLoader()); try { Class<?> clazz = dcl.loadClass("EffectJavaImpl"); efi = (EffectsInterface) clazz.newInstance(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block