I'm trying to read a txt file I have in assets. The structure of the file is like this: 1 [some text] 1 2 [some text] 2 3 [some text] 3 ...
.
What I'm trying to do is to read the [some text]
part corresponding to a specific number, i.e. if i pass the number 1, I'll read from 1 to 1. I've tried this but it didn't work :
AssetManager manager = this.getAssets();
InputStream input = null;
InputStreamReader in = null;
try {
input = manager.open("facil/alexubago/songlyrics.txt");
in = new InputStreamReader(input);
} catch (IOException e1) {
Log.d("ERROR DETECTED", "ERROR WHILE TRYING TO OPEN FILE");
}
try {
char current;
char current2;
String themessage ="" ;
while (in.ready()) {
final Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/Roland.ttf");
final TextView extField = (TextView) findViewById(R.id.thelyrics);
extField.setTypeface(tf);
current = (char) in.read();
int a = 1;
char b = (char) a;
if(current == b){
current2 = (char) in.read();
while(current2 != b){
themessage = themessage+current2;}
extField.setText(themessage);
Log.d("caracter", ""+current);}
Toast.makeText(lyricsfreakgame.this,themessage, Toast.LENGTH_SHORT).show();
}
} catch (IOException e) {
e.printStackTrace();
}