Answers for "How to access assets folder in Android Studio"

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 access assets folder in Android Studio"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language