I have the following code and i try to show text in text-view which in Spanish. When I run app then it showing ? at some places. Can anyone tell me detailed procedure for showing Spanish.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.information);
textview=(TextView) findViewById(R.id.information);
textview.setText(readTxt());
}
private String readTxt(){
InputStream inputStream = getResources().openRawResource(R.raw.info);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
int i;
try {
i = inputStream.read();
while (i != -1)
{
byteArrayOutputStream.write(i);
i = inputStream.read();
}
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
return byteArrayOutputStream.toString();
}
Your readTxt method is wrong.
You are returning a String representation of your
ByteArrayOutputStreamand not the actual String.Try reading the input stream into a
ByteArrayInputStreamand then getting the byte array from it and on that return newString(byteArray);