urbanairship-core/src/main/java/com/urbanairship/iam/InAppMessageCache.java
@WorkerThread
    public static InAppMessageCache newCache(Context context, InAppMessage message) throws IOException {
        File parent;
        synchronized (CACHE_DIRECTORY) {
            parent = new File(context.getCacheDir(), CACHE_DIRECTORY);
            if (!isParentReady) {
                if (parent.exists()) {
                    FileUtils.deleteRecursively(parent);
                }

                if (parent.exists() || parent.mkdirs()) {
                    isParentReady = true;
                } else {
                    throw new IOException("Unable to create cache directory");
                }
            }
        }

        File cacheDir = new File(parent, message.getId());
        int i = 0;
        while (cacheDir.exists()) {
            cacheDir = new File(parent, message.getId() + " " + i);
            i++;
        }

        if (!cacheDir.mkdirs()) {
            throw new IOException("Unable to create cache.");
        }

        return new InAppMessageCache(cacheDir);
    }
/**
     * Factory method.
     *
     * @return An cache instance.
     * @throws java.io.IOException if the cache directory was not able to be created.
     */
Factory method.
@return An cache instance.
@throws java.io.IOException if the cache directory was not able to be created.
Factory method . @return An cache instance . @throws java . io . IOException if the cache directory was not able to be created .
@WorkerThread
    public static InAppMessageCache newCache(Context context, InAppMessage message) throws IOException {
        File parent;
        synchronized (CACHE_DIRECTORY) {
            parent = new File(context.getCacheDir(), CACHE_DIRECTORY);
            if (!isParentReady) {
                if (parent.exists()) {
                    FileUtils.deleteRecursively(parent);
                }
                if (parent.exists() || parent.mkdirs()) {
                    isParentReady = true;
                } else {
                    throw new IOException("Unable to create cache directory");
                }
            }
        }
        File cacheDir = new File(parent, message.getId());
        int i = 0;
        while (cacheDir.exists()) {
            cacheDir = new File(parent, message.getId() + " " + i);
            i++;
        }
        if (!cacheDir.mkdirs()) {
            throw new IOException("Unable to create cache.");
        }
        return new InAppMessageCache(cacheDir);
    }
@ WorkerThread public static InAppMessageCache newCache ( Context context , InAppMessage message ) throws IOException { File parent ; synchronized ( CACHE_DIRECTORY ) { parent = new File ( context . getCacheDir ( ) , CACHE_DIRECTORY ) ; if ( ! isParentReady ) { if ( parent . exists ( ) ) { FileUtils . deleteRecursively ( parent ) ; } if ( parent . exists ( ) || parent . mkdirs ( ) ) { isParentReady = true ; } else { throw new IOException ( "Unable to create cache directory" ) ; } } } File cacheDir = new File ( parent , message . getId ( ) ) ; int i = 0 ; while ( cacheDir . exists ( ) ) { cacheDir = new File ( parent , message . getId ( ) + " " + i ) ; i ++ ; } if ( ! cacheDir . mkdirs ( ) ) { throw new IOException ( "Unable to create cache." ) ; } return new InAppMessageCache ( cacheDir ) ; }
Factory method.
Factory method .