is App Private File Exists - Android App

Android examples for App:App Information

Description

is App Private File Exists

Demo Code


//package com.java2s;

import android.content.Context;
import android.util.Log;

public class Main {
    private static final String LOG_TAG = "AndroidFileUtils";

    /**// w  ww .  ja  va  2s . c  o  m
     * @param pContext
     * @param pFileName
     * @return
     */
    public static boolean isAppPrivateFileExists(Context pContext,
            String pFileName) {
        try {
            String[] fileNamesArr = pContext.fileList();
            if (fileNamesArr == null || fileNamesArr.length == 0) {
                return false;
            }
            for (String existingFileName : fileNamesArr) {
                if (existingFileName.equals(pFileName)) {
                    return true;
                }
            }
            return false;
        } catch (Exception e) {
            Log.e(LOG_TAG, "isAppPrivateFileExists: " + pFileName);
            return false;
        }
    }
}

Related Tutorials