leandro
leandro

Reputation: 41

multiple text files in my raw folder, i want to show them 1 by 1 according to the selected item on listview

i have multiple text files in my raw folder, i want to show them 1 by 1 according to the selected item on listview.

for example i've seleceted "androidTutorial" the text file would be shown must be androidTutorial.txt

BUT HOW? HELP :D

Upvotes: 1

Views: 722

Answers (2)

leandro
leandro

Reputation: 41

Thanks sir :D

  try {



        InputStream is = getAssets().open(selectedinlistview + ".txt");
        int size = is.available();


        byte[] buffer = new byte[size];
        is.read(buffer);
        is.close();


        String text = new String(buffer);


       // TextView tv = (TextView)findViewById(R.id.text);
        TextView helloTxt = (TextView)findViewById(R.id.tvDesc);
        helloTxt.setMovementMethod(new ScrollingMovementMethod());
        helloTxt.setText(text);

    } catch (IOException e) {

Upvotes: 1

henrik
henrik

Reputation: 708

You should have a look at the assets folder. You can list the files in the assets folder and load them by file name. Context.getAssets() and AssetManager are your friends.

Upvotes: 1

Related Questions