1
I wanted to know some tip on how to read large files on Android, as example give the GTFS (Google Transit) files that most of the time is 80 MB
I am placing this data on a server (Firebase) using Android application utility.
However I’m getting errors when reading is in half, IE, when the application overflows memory.
Note: this method I use.
public List<String> readFile(String fileName){
List<String> text = new ArrayList<>();
BufferedReader reader = null;
try {
reader = new BufferedReader(
new InputStreamReader(context.getAssets().open(fileName)));
// do reading, usually loop until end of file reading
String mLine;
if((mLine = reader.readLine()) != null){
//text.add(mLine);
Log.i(TAG, " head " + mLine);
}
while ((mLine = reader.readLine()) != null) {
text.add(mLine);
Log.i(TAG, " line " + mLine);
}
Log.i(TAG,"sucess "+fileName);
} catch (IOException e) {
Log.i(TAG, "error " + fileName);
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
//log the exception
}
}
}
return text;
}