# saveFrame in Android (code share)

**URL:** https://discourse.processing.org/t/saveframe-in-android-code-share/16371
**Category:** Processing for Android
**Created:** [December 13, 2019, 1:38pm UTC](https://discourse.processing.org/t/saveframe-in-android-code-share/16371 "2019-12-13T13:38:04Z")
**Posts on this page:** 1
**Page:** 1

<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: [December 13, 2019, 1:38pm UTC](https://discourse.processing.org/t/saveframe-in-android-code-share/16371/1 "2019-12-13T13:38:04Z")

</div>

The saveFrame function does not work on Android.  
Here is a workaround.

```auto
import android.os.Environment;

int tel = 0, x; 
boolean no_loop = true;
String my_folder = "my_frames"; // Must be an existing folder one level above absolute path
String data_folder_path = new String(Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+my_folder+"/");
PImage pi;

void setup() {
  size(100, 100);
}

void draw() { 
  if (no_loop) {
    background(204); 
    if (x < 100) { 
      line(x, 0, x, 100); 
      x = x + 1;
    } else { 
      no_loop = false;
    } // Saves each frame as line-000001.png, line-000002.png, etc. 
    saveFrame("line-"); // numbers(hashtags) will be included in saveFrame()
  }
}

void saveFrame(String s) {
  int maxHashes=6; 
  tel++;
  String fs = String.format("%1$" + maxHashes + "s", tel).replace(' ', '0');
  pi = get(0, 0, width, height);
  pi.save(data_folder_path+s+fs+".png");
}  

```
