Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- java.io.FileNotFoundException: /storage/emulated/0/SAVE IMAGE EXAMPLE/myimage.png (No such file or directory)
- final PieChart piechart = (PieChart) findViewById(R.id.piechart);
- button2.setOnClickListener(new View.OnClickListener() {
- public void onClick (View v) {
- Toast.makeText(Main.this, "Chart Saved", Toast.LENGTH_SHORT).show();
- piechart.setCenterText("Test");
- Bitmap bitmap;
- OutputStream output;
- bitmap = BitmapFactory.decodeResource(getResources(),R.id.piechart);
- File filepath = Environment.getExternalStorageDirectory();
- File dir = new File(filepath.getAbsolutePath()+"/SAVE IMAGE EXAMPLE");
- dir.mkdirs();
- File file = new File(dir, "myimage.png");
- try {
- output = new FileOutputStream(file);
- bitmap.compress(Bitmap.CompressFormat.PNG, 100, output);
- output.flush();
- output.close();
- }catch(Exception e){
- e.printStackTrace();
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement