I try to read lines randomly from a txt file and show this line in a toast later,
I put the file in assets folder and wrote this code:
BufferedReader reader = new BufferedReader(new FileReader("assets/tips.txt"));
String line = reader.readLine();
List<String> lines = new ArrayList<String>();
while (line != null) {
lines.add(line);
line = reader.readLine();
}
Random r = new Random();
String randomLine = lines.get(r.nextInt(lines.size()));
Toast toast = Toast.makeText(this, randomLine, 30000);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
whats the mistake I did so my app don't show any thing and crash?