I try to read data from the text file temp.txt, which is in my raw folder and displays the contents of the file in the text form βtextβ whenever the βbuttonβ button is pressed, but my application crashes doing this, there is a good chance that I I'm doing it wrong because I'm new to Android and Java programming. I am inserting the code here, any help would be appreciated
case R.id.b:
InputStream is = getResources().openRawResource(R.raw.temp); BufferedReader br = new BufferedReader(new InputStreamReader(is)); try { string = br.readLine(); while(string != null){ st = string; } text.setText(st); } catch (IOException e) {
"st" and "string" are both string variables. I will be glad if anyone can point out another easy way to do the same.
source share