Check if file exists in Asset - Android App

Android examples for App:Assets File

Description

Check if file exists in Asset

Demo Code


//package com.java2s;
import java.io.IOException;
import android.content.res.AssetManager;

public class Main {
    public static boolean exists(AssetManager assetManager,
            String directory, String fileName) throws IOException {
        final String[] assets = assetManager.list(directory);
        for (String asset : assets)
            if (asset.equals(fileName))
                return true;
        return false;
    }/*from   w w w.j a  v a  2 s .  co m*/
}

Related Tutorials