title: Missing android.support.FILE_PROVIDER_PATHS meta-data
body: <p>I am trying to open the pdf file which I downloaded &amp; saved in external storage. But When I open my app its gets crashed and showing following error;</p>
  
  <pre><code>08-31 00:58:31.304 1807-1807/? E/AndroidRuntime: FATAL EXCEPTION: main
  Process: medimanage.corporate.mobile, PID: 1807
      java.lang.RuntimeException: Unable to get provider android.support.v4.content.FileProvider: java.lang.IllegalArgumentException: Missing android.support.FILE_PROVIDER_PATHS meta-data
      at android.app.ActivityThread.installProvider(ActivityThread.java:5856)
      at android.app.ActivityThread.installContentProviders(ActivityThread.java:5445)
      at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5384)
      at android.app.ActivityThread.-wrap2(ActivityThread.java)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1545)
      at android.os.Handler.dispatchMessage(Handler.java:102)
      at android.os.Looper.loop(Looper.java:154)
      at android.app.ActivityThread.main(ActivityThread.java:6119)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
        Caused by: java.lang.IllegalArgumentException: Missing android.support.FILE_PROVIDER_PATHS meta-data
      at android.support.v4.content.FileProvider.parsePathStrategy(FileProvider.java:586)
      at android.support.v4.content.FileProvider.getPathStrategy(FileProvider.java:557)
      at android.support.v4.content.FileProvider.attachInfo(FileProvider.java:375)
      at android.app.ActivityThread.installProvider(ActivityThread.java:5853)
      at android.app.ActivityThread.installContentProviders(ActivityThread.java:5445) 
      at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5384) 
      at android.app.ActivityThread.-wrap2(ActivityThread.java) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1545) 
      at android.os.Handler.dispatchMessage(Handler.java:102) 
      at android.os.Looper.loop(Looper.java:154) 
      at android.app.ActivityThread.main(ActivityThread.java:6119) 
      at java.lang.reflect.Method.invoke(Native Method) 
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) 
  </code></pre>
  
  <p>Following is my async task where I download that pdf file &amp; trying to open it.</p>
  
  <pre><code>package myPackageName.common.postData;    
  public class DownloadFileFromURL extends AsyncTask&lt;String, String, String&gt; {
  
          private ProgressDialog Dialog;
          private Context mContext;
          private String folder_main; //= "TermCondition";
          private String fileName;//= "termCondition.pdf";
          String urlString;
  
          public DownloadFileFromURL(Context mContext, String folderName) {
              this.mContext = mContext;
              this.folder_main = folderName;
              Dialog = new ProgressDialog(this.mContext);
          }
  
          @Override
          protected String doInBackground(String... f_url) {
              try {
                  urlString = f_url[0];
                  URL url = new URL(f_url[0]);
                  File folder = new File(Environment.getExternalStorageDirectory(), this.folder_main);
                  if (folder.exists()) {
                      folder.mkdirs();
                  } 
                  HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
                  urlConnection.connect();
                  InputStream inputStream = urlConnection.getInputStream();
                  FileOutputStream fileOutputStream = new FileOutputStream(Environment.getExternalStorageDirectory() + "/" + "default.pdf");
                  int totalSize = urlConnection.getContentLength();
                  byte[] buffer = new byte[AccessibilityNodeInfoCompat.ACTION_DISMISS];
                  while (true) {
                      int bufferLength = inputStream.read(buffer);
                      if (bufferLength &lt;= 0) {
                          break;
                      }
                      fileOutputStream.write(buffer, 0, bufferLength);
                  }
                  fileOutputStream.close();
              } catch (FileNotFoundException e) {
                  FileLog.e(mContext.getClass().getName(), e);
              } catch (MalformedURLException e2) {
                  FileLog.e(mContext.getClass().getName(), e2);
              } catch (IOException e3) {
                  FileLog.e(mContext.getClass().getName(), e3);
              }
              return null;
          }
  
          public void showPdf() {
              try {
  
                  File file = new File(Environment.getExternalStorageDirectory() + "/" + "default.pdf");
  
                  try {
                      Intent intent = new Intent();
                      intent.setAction(Intent.ACTION_VIEW);
                      if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.N) {
                          intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                          Uri contentUri = FileProvider.getUriForFile(mContext, "medimanage.corporate.mobile.fileprovider", file);
                          intent.setDataAndType(contentUri, "application/pdf");
                      } else {
                          intent.setDataAndType(Uri.fromFile(file), "application/pdf");
                      }
                      mContext.startActivity(intent);
                  } catch (ActivityNotFoundException anfe) {
                      Toast.makeText(mContext, "No activity found to open this attachment.", Toast.LENGTH_LONG).show();
                  }
  
              } catch (Exception e) {
                  FileLog.e(mContext.getClass().getName(), e);
              }
          }
  
          @Override
          protected void onPreExecute() {
              Dialog.setMessage("Downloading...");
              Dialog.setCancelable(false);
              Dialog.setCanceledOnTouchOutside(false);
              Dialog.show();
          }
  
          @Override
          protected void onPostExecute(String s) {
              this.Dialog.dismiss();
              showPdf();
              super.onPostExecute(s);
          }
  
      }
  </code></pre>
  
  <p>Following is AndroidManifest.xml</p>
  
  <pre><code>&lt;application
  ...&gt;
    &lt;provider
        android:name="android.support.v4.content.FileProvider"
        android:authorities="myPackageName.fileprovider"
        android:exported="false"
        android:grantUriPermissions="true"&gt;
            &lt;meta-data
               android:name="android.support.FILE_PROVIDE_PATHS"
               android:resource="@xml/provider_paths" /&gt;
    &lt;/provider&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p>And provider_paths.xml having following code;</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;paths&gt;
      &lt;external-path path="Android/data/" name="files_root" /&gt;
      &lt;external-path path="." name="external_storage_root" /&gt;
  &lt;/paths&gt;
  </code></pre>
  
  <p>I am trying to run above code in API 19 &amp; API 25, but in both devices its gets crash. I am not able to find out where I am going wrong.</p>
  
  <p>I have referred <a href="https://stackoverflow.com/questions/38978198/android-file-provider-illegal-argument-exception">this question</a> &amp; also <a href="https://developer.android.com/reference/android/support/v4/content/FileProvider.html#ProviderDefinition" rel="noreferrer">this link</a> too but not able to find a solution to my issue.</p>