Open a file in assets path - Android App

Android examples for App:Assets File

Description

Open a file in assets path

Demo Code


//package com.java2s;
import android.content.Context;
import java.io.IOException;
import java.io.InputStream;

public class Main {
    /**//from   w  ww  . java  2  s  .c o  m
     * Open a file in assets path
     *
     * @param context
     * @param assetFilePath
     * @return
     */
    public static InputStream open(final Context context,
            final String assetFilePath) {
        try {
            return context.getAssets().open(assetFilePath);
        } catch (IOException e) {
            return null;
        }
    }
}

Related Tutorials