List of usage examples for android.support.v4.content ContextCompat ContextCompat
ContextCompat
From source file:net.sf.fakenames.db.ScriptProvider.java
private void doChores() { ResourceGroovyMethods.deleteDir(new ContextCompat().getCodeCacheDir(context)); ResourceGroovyMethods.deleteDir(new File(context.getCacheDir().getAbsolutePath() + "/sandbox/")); final File externalCaches = context.getExternalCacheDir(); if (externalCaches != null) ResourceGroovyMethods.deleteDir(new File(externalCaches, "/sandbox/")); }
From source file:com.android.build.gradle.internal.incremental.fixture.ClassEnhancement.java
private static Map<String, ClassLoader> setUpEnhancedClassLoaders(final ClassLoader mainClassLoader, final Map<String, File> compileOutputFolders, final boolean tracing) { return Maps.transformEntries(compileOutputFolders, new Maps.EntryTransformer<String, File, ClassLoader>() { @Override//from ww w .ja v a2 s .c om public ClassLoader transformEntry(@Nullable String patch, @Nullable File compileOutputFolder) { Context context = InstrumentationRegistry.getContext(); File optimizedDir = new ContextCompat().getCodeCacheDir(context); try { InputStream is = context.getAssets().open(compileOutputFolder.getPath() + "/classes.dex"); File output; try { File patchDir = new File(context.getDir("patches", Context.MODE_PRIVATE), patch); patchDir.mkdir(); output = new File(patchDir, patch + ".dex"); Files.asByteSink(output).writeFrom(is); } finally { is.close(); } return new DexClassLoader(output.getAbsolutePath(), optimizedDir.getAbsolutePath(), null, ClassEnhancement.class.getClassLoader()); } catch (IOException e) { throw new RuntimeException(e); } } }); }