load file from asset folder via Context - Android App

Android examples for App:Assets File

Description

load file from asset folder via Context

Demo Code


//package com.java2s;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import android.content.Context;

public class Main {
    public static List<String> loadBusList(Context context)
            throws IOException {
        InputStream is = context.getAssets().open("list.txt");
        BufferedReader br = new BufferedReader(new InputStreamReader(is));
        List<String> list = new ArrayList<String>();
        String line;// w w  w .ja v  a2s .  co  m
        while ((line = br.readLine()) != null) {
            list.add(line);
        }
        br.close();
        return list;
    }
}

Related Tutorials