Context getDir - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Context getDir method.

This code example shows how to use the following methods:getClassLoader, getDir, getPackageManager, getPackageName
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getDir
This code example shows how to use the following methods:getDir
		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;
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getDir
	 */ 
	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);
 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getDir
                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 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:loadClass
            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();
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:loadClass
 
	    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();
	    } 
 
	} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:loadClass
    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)) {
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
            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);
        } 
    } 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:loadClass
    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 
5
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Context getDir Questions & Answers:

getDir Method Overview
Retrieve, creating if needed, a new directory in which the application can place its own custom data files.
See Code Examples for other Android Context Methods: