title: How to read a text file and display in a text view?
body: <p>When I navigate to a page in the app, I expect the text from the text file to be displayed but it isn't. Am I missing something?</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_content);
  
      Button backButton = findViewById(R.id.button_back);
      Button selectAnotherButton = findViewById(R.id.button_select_another);
  
      TextView contentText = findViewById(R.id.content_text);
      String text = "";
  
      try {
          // file to inputstream
          InputStream input = getAssets().open("jokes.txt");
          int size = input.available();
          byte[] buffer = new byte[size];
          input.read(buffer);
          input.close();
          // byte buffer into a string
          text = new String(buffer);
  
      } catch (Exception e) {
          System.out.println(e);
      }
  
      contentText.setText(text);
  }
  </code></pre>