title: Unable to export bitmape onto csv
body: <p>I want to export an image to csv, but my application crashes whenever trying to do this. In my application I have a question "which brands do you recognize ?", and wanted to let the user answer by selecting a checkbox along with the corresponding ImageView. The objective is to save both question(a string) and answer(an image) to csv or doc by clicking on a button, but the application crashes and only the string is printed in the generated csv.</p>
  
  <pre><code>public class Page3 extends Activity implements OnClickListener {
  Intent myIntent;
  TextView question4;
  CheckBox one, two, three;
  ImageView one1, two2, three3;
  Bitmap bmp1, bmp2, bmp3;
  String ques4;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.page3);
      initialize();
  }
      private void initialize() {
      Button prev = (Button) findViewById(R.id.page3previous);
      Button next = (Button) findViewById(R.id.page3next);
      next.setOnClickListener(this);
      prev.setOnClickListener(this);
      question4 = (TextView) findViewById(R.id.question4tv);
      one1 = (ImageView) findViewById(R.id.imageView1);
      two2 = (ImageView) findViewById(R.id.imageView2);
      three3 = (ImageView) findViewById(R.id.imageView3);
      one = (CheckBox) findViewById(R.id.checkBox1);
      two = (CheckBox) findViewById(R.id.checkBox2);
      three = (CheckBox) findViewById(R.id.checkBox3);
  }
      @Override
  public void onClick(View arg0) {
      switch (arg0.getId()) {
      case R.id.page3previous:
          myIntent = new Intent(Page3.this, Page2.class);
          startActivity(myIntent);
          break;
      case R.id.page3next:
          ques4 = question4.getText().toString();
          if (one.isChecked()) {
              one1.buildDrawingCache();
              bmp1 = one1.getDrawingCache();
              setBitMapOneTwoThree(bmp1, bmp3, bmp2, ques4);
          } else if (two.isChecked()) {
              two2.buildDrawingCache();
              bmp2 = two.getDrawingCache();
              setBitMapOneTwoThree(bmp1, bmp3, bmp2, ques4);
          } else if (three.isChecked()) {
              three3.buildDrawingCache();
              bmp3 = three3.getDrawingCache();
              setBitMapOneTwoThree(bmp1, bmp3, bmp2, ques4);
          } else if (two.isChecked() &amp;&amp; one.isChecked()) {
              one1.buildDrawingCache();
              bmp1 = one1.getDrawingCache();
              two2.buildDrawingCache();
              bmp2 = two.getDrawingCache();
              setBitMapOneTwoThree(bmp1, bmp3, bmp2, ques4);
          } else if (two.isChecked() &amp;&amp; three.isChecked()) {
              two2.buildDrawingCache();
              bmp2 = two.getDrawingCache();
              three3.buildDrawingCache();
              bmp3 = three3.getDrawingCache();
              setBitMapOneTwoThree(bmp1, bmp3, bmp2, ques4);
          } else if (one.isChecked() &amp;&amp; three.isChecked()) {
              three3.buildDrawingCache();
              bmp3 = three3.getDrawingCache();
              one1.buildDrawingCache();
              bmp1 = one1.getDrawingCache();
              setBitMapOneTwoThree(bmp1, bmp3, bmp2, ques4);
          } else if (one.isChecked() &amp;&amp; three.isChecked() &amp;&amp; two.isChecked()) {
              three3.buildDrawingCache();
              bmp3 = three3.getDrawingCache();
              two2.buildDrawingCache();
              bmp2 = two.getDrawingCache();
              one1.buildDrawingCache();
              bmp1 = one1.getDrawingCache();
              setBitMapOneTwoThree(bmp1, bmp3, bmp2, ques4);
          }
          myIntent = new Intent(Page3.this, Page4.class);
          startActivity(myIntent);
          break;
      }
  }
      private void setBitMapOneTwoThree(Bitmap bmp12, Bitmap bmp32, Bitmap bmp22,
          String ques42) {
      bmp12 = this.bmp1;
      bmp32 = this.bmp3;
      bmp22 = this.bmp2;
      ques42 = this.ques4;
      generateCsvFile("Image.csv", bmp12, bmp32, bmp22, ques42);
  }
  
  private void generateCsvFile(String string, Bitmap bmp12, Bitmap bmp32,
          Bitmap bmp22, String ques42) {
      try {
          File root = Environment.getExternalStorageDirectory();
          File gpxfile = new File(root, string);
          FileWriter writer = new FileWriter(gpxfile);
          FileOutputStream fOut = new FileOutputStream(gpxfile);
          writer.append(ques42);
          writer.flush();
          writer.close();
          bmp12.compress(Bitmap.CompressFormat.PNG, 85, fOut);
          bmp32.compress(Bitmap.CompressFormat.PNG, 85, fOut);
          bmp22.compress(Bitmap.CompressFormat.PNG, 85, fOut);
          fOut.flush();
          fOut.close();
      } catch (IOException e) {
          e.printStackTrace();
      }
  }
  }
  </code></pre>