title: How to save the current image from viewpager?
body: <p>I have images in a <code>ViewPager</code> and I want user to can save the current image by click on a button to save the image to sd card in phone</p>
  
  <p>This is my demoactivity.java</p>
  
  <pre><code>public class DemoActivity extends Activity {
  Button play;
  MediaPlayer mp;
  
  public int playstop = 0;
  
  private Button extisaw;
  public void onCreate(Bundle ww) {
      super.onCreate(ww);
      setContentView(R.layout.activity_main);
      play = (Button) findViewById(R.id.saw);
      mp = MediaPlayer.create(this, R.raw.raj);
      show1();
      show2();
      play.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  if (playstop == 0) {
                      MediaHandler(mp, 1);
                      mp.start();
                      playstop = 1;
  
                  } else {
                      MediaHandler(mp, 2);
                      mp.pause();
                      playstop = 0;
                  }
              }
          });
  }
  
  private void show2()
  {
      // TODO: Implement this method
  
      this.extisaw =
          (Button)this.findViewById
      (R.id.about);
      this.extisaw.setOnClickListener
      (new OnClickListener() {
              @Override
              public void onClick(View v) {
                  finish();
              }
      });}
  
  public void MediaHandler
  (MediaPlayer mp, int e) {
      if (e == 1) {
          mp.start();
      } else {
          mp.pause();
      }
  }
  
  public void show1() {
      ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
      ImagePagerAdapter adapter = new ImagePagerAdapter();
      viewPager.setAdapter(adapter);
  }
  
  private class ImagePagerAdapter extends PagerAdapter {
      private int[] mImages = new int[]{
          R.drawable.a1, R.drawable.a2,
          R.drawable.a3, R.drawable.a4,
          R.drawable.a5, R.drawable.a6,
          R.drawable.a7, R.drawable.a8
          , R.drawable.a9, R.drawable.a10, R.drawable.a11, R.drawable.a12
          , R.drawable.a13, R.drawable.a14, R.drawable.a15
          , R.drawable.a16, R.drawable.a17, R.drawable.a18, R.drawable.a19
          , R.drawable.a20, R.drawable.a21, R.drawable.a22, R.drawable.a23
          ,
          R.drawable.a24, R.drawable.a25,
          R.drawable.a26, R.drawable.a27
          , R.drawable.a29,
          R.drawable.a30, R.drawable.a31
          , R.drawable.a32, R.drawable.a33, R.drawable.a34, R.drawable.a35
          , R.drawable.a36, R.drawable.a37, R.drawable.a38
          , R.drawable.a39, R.drawable.a40, R.drawable.a42
          , R.drawable.a43, R.drawable.a44, R.drawable.a45, R.drawable.a46,
          R.drawable.a47, R.drawable.a48,
          R.drawable.a49
          , R.drawable.a51,
          R.drawable.a52, R.drawable.a53
          , R.drawable.a54, R.drawable.a55, R.drawable.a56
          , R.drawable.a58, R.drawable.a59, R.drawable.a60
          , R.drawable.a61, R.drawable.a62, R.drawable.a63
          , R.drawable.a64, R.drawable.a65, R.drawable.a66, R.drawable.a67, R.drawable.a68, R.drawable.a69
  
  
          , R.drawable.a70,
          R.drawable.a71, R.drawable.a72
          , R.drawable.a73, R.drawable.a74, R.drawable.a75
          , R.drawable.a76, R.drawable.a77, R.drawable.a78
          , R.drawable.a79, R.drawable.a80, R.drawable.a81
          , R.drawable.a82, R.drawable.a83, R.drawable.a84, R.drawable.a85, R.drawable.a86, R.drawable.a87
  
          , R.drawable.a88,
          R.drawable.a89, R.drawable.a90
          , R.drawable.a91, R.drawable.a93
          , R.drawable.a94, R.drawable.a95, R.drawable.a96
          , R.drawable.a97, R.drawable.a98, R.drawable.a99
  
      };
  
      @Override
      public int getCount() {
          return mImages.length;
      }
  
      @Override
      public boolean isViewFromObject(View view, Object object) {
          return view == ((ImageView) object);
      }
  
      @Override
      public Object instantiateItem(ViewGroup container, int position) {
          Context context = DemoActivity.this;
          ImageView imageView = new ImageView(context);
          int padding = context.getResources().getDimensionPixelSize(
              R.dimen.padding_medium);
          imageView.setPadding(padding, padding, padding, padding);
          imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
          imageView.setImageResource(mImages[position]);
          ((ViewPager) container).addView(imageView, 0);
          return imageView;
      }
  
      @Override
      public void destroyItem(ViewGroup container, int position, Object object) {
          ((ViewPager) container).removeView((ImageView) object);
      }
  }
  </code></pre>
  
  <p>}</p>