title: Android - Allow user to open text files with app
body: <p>I fixed my problem with the help of the link to <a href="http://www.vogella.com" rel="nofollow">http://www.vogella.com</a> and further searching.</p>
  
  <p>• Android Manifest:
   
      
      </p>
  
  <pre><code>&lt;uses-sdk android:minSdkVersion="8" /&gt;
  &lt;supports-screens android:resizeable="true" android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:anyDensity="true" /&gt;
  &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"&gt;&lt;/uses-permission&gt;
  &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"&gt;&lt;/uses-permission&gt;
  &lt;application
      android:icon="@drawable/ic_launcher"
      android:label="@string/app_name" android:process="IPP.EZPadd"&gt;
      &lt;activity
          android:label="@string/app_name"
          android:name=".EZPaddActivity" &gt;
          &lt;intent-filter &gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
          &lt;intent-filter &gt;
              &lt;action android:name="android.intent.action.VIEW" /&gt;
              &lt;category android:name="android.intent.category.DEFAULT" /&gt;
              &lt;data android:scheme="file" /&gt;
              &lt;data android:mimeType="text/plain" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p></p>
  
  <p>• Java Activity:
   </p>
  
  <pre><code>public void open_on_start()
      {
          Intent i = getIntent();
          Uri data = i.getData();
          if (data == null)
          {
              return;
          }
          URL url;
          String startFile = "";
          try
          {
              url = new URL(data.getScheme(), data.getHost(), data.getPath());
              startFile = url.toString().replace("file:", "");
          }
          catch (Exception ex)
          {
              Toast.makeText(this, "Error:\n" + ex.getMessage().toString(), Toast.LENGTH_LONG).show();
              return;
          }
          if (startFile == null)
          {
              return;
          }
          StringBuilder text = new StringBuilder();  
          can = false;
          sel = false;
          try
          {
              file = new File(CurDir, startFile);
              reader = new BufferedReader(new FileReader(file));  
              String line;
              while ((line = reader.readLine()) != null)
              {
                  text.append(line);  
                  text.append('\n');  
              }
          }
          catch (Exception e)
          {
              Toast.makeText(this, "Error:\n" + e.getMessage().toString(), Toast.LENGTH_LONG).show();
          }
          TextEditor.setText(text);
          FileName.setText(startFile);
      }
  </code></pre>
  
  <p>Thank you Simon for the link, it was very helpful. I just skimmed through it at first that is why I ran into that problem with it not loading the file.</p>