Java Code Examples for android.content.Context#getCodeCacheDir()

The following examples show how to use android.content.Context#getCodeCacheDir() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShareObjCheckUtil.java    From SocialSdkLibrary with Apache License 2.0 5 votes vote down vote up
private static boolean isAppCachePath(Context context, String fullPath) {
    File externalCacheDir = context.getExternalCacheDir();
    if (externalCacheDir != null) {
        if (fullPath.contains(externalCacheDir.getAbsolutePath())) {
            return true;
        }
    }
    File cacheDir = context.getCacheDir();
    if (fullPath.contains(cacheDir.getAbsolutePath())) {
        return true;
    }
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        File codeCacheDir = context.getCodeCacheDir();
        if (fullPath.contains(codeCacheDir.getAbsolutePath())) {
            return true;
        }
    }
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
        File dataDir = context.getDataDir();
        if (fullPath.contains(dataDir.getAbsolutePath())) {
            return true;
        }
    }
    File filesDir = context.getFilesDir();
    if (fullPath.contains(filesDir.getAbsolutePath())) {
        return true;
    }
    return false;
}
 
Example 2
Source File: DexLoaderBuilder.java    From PowerFileExplorer with GNU General Public License v3.0 4 votes vote down vote up
public static DexClassLoader fromBytes(Context context, final byte[] dexBytes) throws Exception {

        if (null == context) {
            throw new RuntimeException("No context provided");
        }

        final String dexFileName = "internal.dex";

        final File dexInternalStoragePath = new File(context.getDir("dex", Context.MODE_PRIVATE), dexFileName);

        if (!dexInternalStoragePath.exists()) {

            prepareDex(dexBytes, dexInternalStoragePath);
        }

        final File optimizedDexOutputPath = context.getCodeCacheDir();

        DexClassLoader loader = new DexClassLoader(dexInternalStoragePath.getAbsolutePath(),
                optimizedDexOutputPath.getAbsolutePath(), null, context.getClassLoader().getParent());

        dexInternalStoragePath.delete();
        return loader;
    }
 
Example 3
Source File: DexLoaderBuilder.java    From android-classyshark with Apache License 2.0 4 votes vote down vote up
public static DexClassLoader fromBytes(Context context, final byte[] dexBytes) throws Exception {

        if (null == context) {
            throw new RuntimeException("No context provided");
        }

        String dexFileName = "internal.dex";

        final File dexInternalStoragePath = new File(context.getDir("dex", Context.MODE_PRIVATE), dexFileName);

        if (!dexInternalStoragePath.exists()) {

            prepareDex(dexBytes, dexInternalStoragePath);
        }

        final File optimizedDexOutputPath = context.getCodeCacheDir();

        DexClassLoader loader = new DexClassLoader(dexInternalStoragePath.getAbsolutePath(),
                optimizedDexOutputPath.getAbsolutePath(), null, context.getClassLoader().getParent());

        dexInternalStoragePath.delete();

        return loader;
    }
 
Example 4
Source File: ContextCompatApi21.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
public static File getCodeCacheDir(Context context) {
    return context.getCodeCacheDir();
}