title: How to put a video file in android custom content provider
body: <p>I have a video file which I want to store in custom content provider. And after that, I want to read it and want to play it through Uri.</p>
  <p>Below is my code.</p>
  <pre><code>package com.videocon.nds;
  
  public class FileProvider extends ContentProvider {
      public static final Uri CONTENT_URI=Uri.parse(&quot;content://com.videocon.nds/&quot;);
      private static final HashMap&lt;String, String&gt; MIME_TYPES=new HashMap&lt;String, String&gt;();
     static {
      MIME_TYPES.put(&quot;.mp4&quot;, &quot;video/mp4&quot;);
     }
  
  @Override
  public boolean onCreate() {
  File f=new File(getContext().getFilesDir(), &quot;Holy.mp4&quot;);
  
  if (!f.exists()) {
      AssetManager assets=getContext().getResources().getAssets();
  
      try {
      copy(assets.open(&quot;Holy.mp4&quot;), f);
      }
      catch (IOException e) {
      Log.e(&quot;FileProvider&quot;, &quot;Exception copying from assets&quot;, e);
  
      return(false);
      }
  }
  
  return(true);
  }
  
  @Override
  public String getType(Uri uri) {
  String path=uri.toString();
  
  for (String extension : MIME_TYPES.keySet()) {
      if (path.endsWith(extension)) {
      return(MIME_TYPES.get(extension));
      }
  }
  
  return(null);
  }
  
  @Override
  public ParcelFileDescriptor openFile(Uri uri, String mode)
      throws FileNotFoundException {
  File f=new File(getContext().getFilesDir(), uri.getPath());
  
  if (f.exists()) {
      return(ParcelFileDescriptor.open(f,
          ParcelFileDescriptor.MODE_READ_ONLY));
  }
  
  throw new FileNotFoundException(uri.getPath());  
  }
  
  @Override
  public Cursor query(Uri url, String[] projection, String selection,
      String[] selectionArgs, String sort) {
  throw new RuntimeException(&quot;Operation not supported&quot;);
  }
  
  @Override
  public Uri insert(Uri uri, ContentValues initialValues) {
  
  throw new RuntimeException(&quot;Operation not supported&quot;);
  }
  
  @Override
  public int update(Uri uri, ContentValues values, String where, String[] whereArgs) {
  throw new RuntimeException(&quot;Operation not supported&quot;);
  }
  
  @Override
  public int delete(Uri uri, String where, String[] whereArgs) {
  throw new RuntimeException(&quot;Operation not supported&quot;);
  }
  
  static private void copy(InputStream in, File dst) throws IOException {
  FileOutputStream out=new FileOutputStream(dst);
  byte[] buf=new byte[1024];
  int len;
  
  while((len=in.read(buf))&gt;0) {
      out.write(buf, 0, len);
  }
  
  in.close();
  out.close();
  }
  }
  </code></pre>