I have a path stored in my database to a file text1.txt
, which contains the text I want to display. The file is in the assets folder, assets/text1.txt.
How do I open this file and display its content?
The code is:
if (placetext != null) {
try
{
InputStream textpath = getAssets().open(text);
//Bitmap bit = BitmapFactory.decodeStream(textpath);
placetext.setText(text);
//placetext.setText(text);
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
...and the view on the emulator is just text1.txt not the content of the file.
i already have the solution
String text12 = b.getString("texts") try { InputStream is = getAssets().open(text12); // int size = is.available();
byte[] buffer = new byte[size]; is.read(buffer); is.close(); String text= new String(buffer); placetext = (TextView)findViewById(R.id.detailText2); placetext.setText(text); } catch (IOException e) { throw new RuntimeException(e); }