title: ActivityNotFoundException when try to open pdf file in android application
body: <p>I'm new to android development. I'm trying to create a PDF file using android application and view through the application.there is no error when i creating the pdf file, but it throws and exception when i try to open the pdf file. I also set the read and write permission in the manifest file.
  here is my method to open the pdf file</p>
  
  <pre><code>void openPdf()
  {
      Intent intent = new Intent(Intent.ACTION_VIEW);
      String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/PDF";
  
      File file = new File(path, "demo.pdf");
      intent.setDataAndType( Uri.fromFile( file ), "application/pdf" );
      startActivity(intent.setDataAndType( Uri.fromFile( file ), "application/pdf" ));
      intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
      Intent target = Intent.createChooser(intent, "Open File");
      try {
          startActivity(target);
      } catch (ActivityNotFoundException e) {
          Log.e("PDFCreator", "ActivityNotFoundException:" + e);
      } 
  }
  </code></pre>
  
  <p>this the error that i get</p>
  
  <pre><code> 03-28 05:47:59.760: E/AndroidRuntime(5844): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=file:///storage/sdcard/PDF/demo.pdf typ=application/pdf }
  </code></pre>
  
  <p>here is my manifest file</p>
  
  <pre><code>   &lt;?xml version="1.0" encoding="utf-8"?&gt;
    &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.isuru.mypdf"
  android:versionCode="1"
  android:versionName="1.0" &gt;
  
  &lt;uses-sdk
      android:minSdkVersion="8"
      android:targetSdkVersion="18" /&gt;
  
  &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
  
  &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /&gt;
  &lt;application
      android:allowBackup="true"
      android:icon="@drawable/ic_launcher"
      android:label="@string/app_name"
      android:theme="@style/AppTheme" &gt;
      &lt;activity
          android:name="com.isuru.mypdf.MainActivity"
          android:label="@string/app_name" &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;/activity&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p></p>
  
  <p>why this error comes,please help me to solve the problem. weather i have to change the cored or add some cording. thank you very much</p>