I’ve a text file in the RAW DIrectory
called test.txt
My java Code checks correctly the test.txt file with device language german. How can i check the EN-File, when the device language is english?
I think in line 3 of my code i have to set an if-else block to proof the raw directory?
THX a lot for HELP!
My Java Code (works):
TextView HelpTxtMain;
HelpTxtMain = (TextView)findViewById(R.id.TextViewMain);
HelpTxtMain.setText(readTxtDe());
private String readTxtDe() {
InputStream inputStream = getResources().openRawResource(R.raw.test);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
int i;
try {
i = inputStream.read();
while (i != -1)
{
byteArrayOutputStream.write(i);
i = inputStream.read();
}
inputStream.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return byteArrayOutputStream.toString();
}
Try to rename the file to “test.txt” and put them into the directories
values-deandvalues-enor better out the english file into thevaluesdirectory to set the english language as the default language.Android will select the right file based on the currient language.