Answers for "how to open the file from the assets folder in android"

1

how to read file from assets folder in android

BufferedReader reader = null;
try {
    reader = new BufferedReader(
        new InputStreamReader(getAssets().open("filename.txt"), "UTF-8")); 

    // do reading, usually loop until end of file reading 
    String mLine;
    while ((mLine = reader.readLine()) != null) {
       //process line
       ...
    }
} catch (IOException e) {
    //log the exception
} finally {
    if (reader != null) {
         try {
             reader.close();
         } catch (IOException e) {
             //log the exception
         }
    }
}
Posted by: Guest on April-11-2020

Code answers related to "how to open the file from the assets folder in android"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language