# Android Cannot get access to data folder

**URL:** <https://discourse.processing.org/t/android-cannot-get-access-to-data-folder/14636>\
**Category:** Processing for Android\
**Created:** [October 12, 2019, 5:46pm UTC](https://discourse.processing.org/t/android-cannot-get-access-to-data-folder/14636 "2019-10-12T17:46:19Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [October 12, 2019, 8:21pm UTC](https://discourse.processing.org/t/android-cannot-get-access-to-data-folder/14636/2 "2019-10-12T20:21:43Z")

</div>

Hope this helps.  
Edit: Of course if you want to save it to your sketch data folder you have to use “/Sketchbook/yourSketch/data” instead of “/imageFolder” If a directory not exist it will be created.

```auto
import android.os.Environment;

PImage save;
PGraphics square;

String s = "myImage.png";

void setup() {
  size(200, 200);
  square = createGraphics(100, 100);
  square.beginDraw();
  square.fill(0, 0, 150);
  square.rect(0, 0, 100, 100);
  square.endDraw();
  image(square, 0, 0);
  save = get(0, 0, 100, 100);
  saveImage(s);
}

void draw() {
}
 

  void saveImage(String s) {
   try
      {
     String directory = new String(Environment.getExternalStorageDirectory().getAbsolutePath() + "/imgFolder");
     File imgFolder = new File(directory);
      if (!imgFolder.exists()) {
      boolean success = true;
       success = imgFolder.mkdirs();
    }
      save.save(directory + "/" + s);
          println("File saved successfully.");
  } 
     catch (Exception e) 
        {
       println("Error while saving file: " + e);
  }
}

```

---

_[View the full topic](https://discourse.processing.org/t/android-cannot-get-access-to-data-folder/14636)._
