title: android-How to enable cache or buffering when videoView have downloaded a video
body: <p>I'm showing video from internet by using videoView  . it's ok and working fine . the only problem is , it plays the video every time I come to activity and it starts from 0 . </p>
  
  <p>It's very bad , I want to cache videos or save them somehow to give users shows the videos without downloading them from scratch  .</p>
  
  <p>this is my code for playing videos :</p>
  
  <pre><code>@Override
  public void onActivityCreated(Bundle savedInstanceState) {
      super.onActivityCreated(savedInstanceState);
      Bundle bundle = getActivity().getIntent().getExtras();
      url=bundle.getString("url");
      onvan=bundle.getString("onvan");
      playvideo();
  }
  
  private void playvideo() {
      progressDialog = new ProgressDialog(getActivity());
      progressDialog.setMessage("Downloading");
      progressDialog.setCancelable(true);
      progressDialog.show();
  
      final VideoView videoView =(VideoView)view.findViewById(R.id.videoView);
      MediaController mediaController= new MediaController(getActivity());
      mediaController.setAnchorView(videoView);        
      Uri uri=Uri.parse("http://example.com/uploads/"+url); 
      videoView.setMediaController(mediaController);
      videoView.setVideoURI(uri);        
      videoView.requestFocus();
  
      videoView.start();
  
      videoView.setMediaController(mediaController);
  
      try{      
      videoView.setMediaController(mediaController);
      videoView.setVideoURI(uri);
  
      } catch (Exception e) {
        e.printStackTrace();
       }
  
      videoView.requestFocus();
  
      videoView.setOnPreparedListener(new OnPreparedListener() {
  
      public void onPrepared(MediaPlayer arg0) {
          progressDialog.dismiss();
          videoView.start();
      }
      });
  
  }
  </code></pre>
  
  <p>The video sizes are between 10mb to 50mb . </p>
  
  <p>How can I do so ?</p>