title: How to retrieve data from internal storage in a FragmentActivity?
body: <p>Hi everyone I'm currently developing an android app that writes a JSON data to internal storage and it should be retrieve from a <strong>class</strong> that extends <strong>FragmentActivity</strong>. </p>
  
  <p>This is the code on how I write the data to the internal storage:</p>
  
  <pre><code>private void createFile(String data) throws IOException{
      FileOutputStream fos = openFileOutput("userObj", Context.MODE_PRIVATE);
      fos.write(data.getBytes());
      fos.close();
  }
  </code></pre>
  
  <p>and when I'm retrieving the data from a <strong>class</strong> that extends <strong>Activity</strong>
  I <strong>CAN</strong> read the data like this</p>
  
  <pre><code>private void readFile() throws IOException, JSONException {
  
       FileInputStream fis = openFileInput("userObj");
       BufferedInputStream bis = new BufferedInputStream(fis);
       StringBuffer b = new StringBuffer();
  
       while (bis.available() != 0){
          char c = (char) bis.read();
          b.append(c);
       }
  
       bis.close();
       fis.close();
       JSONObject data = new JSONObject(b.toString());
       Log.d(Constants.DATA,  data.getString("qr_code_png"));
  }
  </code></pre>
  
  <p>but when I'm retrieving the data from a <strong>class</strong> that extends a <strong>FragmentActivity</strong> with the same code I <strong>Cannot retrieve</strong>:</p>
  
  <pre><code>  public void readFile() throws IOException, JSONException {
          FileInputStream fis = openFileInput("userObj");
          BufferedInputStream bis = new BufferedInputStream(fis);
          StringBuffer b = new StringBuffer();
          while (bis.available() != 0){
              char c = (char) bis.read();
              b.append(c);
          }
          bis.close();
          fis.close();
          JSONObject data = new JSONObject(b.toString());
          Log.d(Constants.DATA,  data.getString("qr_code_png"));
  
      }
  </code></pre>
  
  <p>How can I retrieve the saved data from internal storage from a class that extends fragment activity? </p>