Android: How to save to Pictures folder

About Monkey 2 Forums Monkey 2 Programming Help Android: How to save to Pictures folder

This topic contains 10 replies, has 4 voices, and was last updated by  Nalle 6 months, 2 weeks ago.

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
  • #15545


    Hello everyone,

    How in Monkey2 the Pictures folder of Android systems can be retrieved?

    I’m currently using path “sdcard/Pictures/”, but this probably isn’t the best way to do it.

    I would like to have the pictures to be visible with computer too, so that it would be easy to transfer the files from Android device to computer.

    The way I’m currently done it, the user has to copy or move first the file on Android device, which makes it visible to a computer too.



    Hi. There is the function  GetSpecialDir:String( name:String ) but it understand only “internal” and “external” params for android,

    but you can extend it by changing this file


    add one more else  branch:

    and rebuild std module for android target.



    I will test and add realisation for all external dirs.



    With my new Samsung Galaxy A6+ saving to Pictures folder doesn’t work. I checked SavePixmap state from the debugger, it was false and nothing was saved. Has anyone else tried this?


    Mark Sibly

    It may be a permissions issue, try something like this…

    RequestPermissions( New String[][(“android.permission.WRITE_EXTERNAL_STORAGE”),Lambda( results:UInt[] )

    End )

    I have no idea if this is the correct permission to ask for though, more here:



    As default there is in the Android Manifest this permission: WRITE_EXTERNAL_STORAGE

    I also thought, that could it be permissions issue, because ..Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_PICTURES ) is the correct way to get the Pictures folder.



    if setting it to targetSdkVersion 21 works fine, then we have the same problem. working on it



    this seem to be what has changed to increase the security in Android filesystem, i dont have any pacakaged solution yet as i dont have much time before Christmas. But it might give an idea to ppl.



    From Android version 6 (API >= 23) one must ask at run-time permission for example to Pictures folder.

    This was my first try to do Android coding inside the Android Studio and I came up with this not working skeleton, that is based on Google’s example code:

    Edit: Also this in addition:


    Has anyone a working solution?

    Working solution should ask the user, if the user agrees to app’s writing to external storage.

    edit: Link to original code:



    I made a new code, this little code (needs some improvement) seems to work.

    It prompts the user (system feature) if the app may write to external storage, after permission, when the permission is granted, the picture is saved to Pictures folder!

    We should add proper code to Monkey2 modules to get more Android features like Camera.



    I found this old thread:

    The permissions can be asked simply in nice Monkey2 code. 🙂

    Though, I had at first problem with the following line:

    RequestPermissions(permissions,Lambda( results:Int[] )

    Error : Can’t find overload for ‘RequestPermissions’ with argument types (monkey.types.String[],Void(monkey.types.Int[]))

    If it is changed to: RequestPermissions( permissions,Lambda( results:ResultType[] ) it can be compiled.

Viewing 11 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic.