# \[Bug\] java.lang.RuntimeException: onRequestPermission SaveSettings() already added for this instance

**URL:** <https://discourse.processing.org/t/bug-java-lang-runtimeexception-onrequestpermission-savesettings-already-added-for-this-instance/29074>\
**Category:** Processing for Android\
**Created:** [April 2, 2021, 4:47pm UTC](https://discourse.processing.org/t/bug-java-lang-runtimeexception-onrequestpermission-savesettings-already-added-for-this-instance/29074 "2021-04-02T16:47:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kitulous](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kitulous/32/12302_2.png) [@Kitulous](https://discourse.processing.org/u/Kitulous)\
**Post date:** [April 2, 2021, 4:47pm UTC](https://discourse.processing.org/t/bug-java-lang-runtimeexception-onrequestpermission-savesettings-already-added-for-this-instance/29074/1 "2021-04-02T16:47:19Z")

</div>

I had to edit the title because it didn’t let me post, the correct title is: “[Bug] java.lang.RuntimeException: onRequestPermissionSaveSettings() already added for this instance”

Hi. So whenever I try to save a file, I need to request a permission to do this, right?  
So I do this with a code like this:

```auto
requestPermission("android.permission.WRITE_EXTERNAL_STORAGE", "onRequestPermissionSaveSettings");

```

It is called on an instance of my PApplet.

So as you see, I have a callback function called onRequestPermissionSaveSettings.  
It is defined in my PApplet.

When I call the aforementioned requestPermission function once, everything is great – the code is run and the file is saved.

When I call it the second time, though, it gives out this error:

```java
W/System.err: java.lang.RuntimeException: onRequestPermissionSaveSettings() already added for this instance of com.kitulous.chineselearn2.app.App
        at processing.core.PApplet.die(PApplet.java:2836)
        at processing.core.PApplet$RegisteredMethods.add(PApplet.java:1047)
        at processing.core.PApplet.registerWithArgs(PApplet.java:1170)
        at processing.core.PApplet.requestPermission(PApplet.java:744)
        at processing.core.PApplet.requestPermission(PApplet.java:739)
        at /* my app code that calls requestPermission function */

```

So I presume the error is in the Processing for Android code.  
Well, I guess, since in PApplet#registerWithArgs(String, Object, Class\<?\>[]) it adds a method without checking if it’s already there (and it definitely is already there since I have already called that function previously).

---

<div class="post-metadata">

**Author:** ![akenaton](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akenaton](https://discourse.processing.org/u/akenaton)\
**Post date:** [April 3, 2021, 5:35pm UTC](https://discourse.processing.org/t/bug-java-lang-runtimeexception-onrequestpermission-savesettings-already-added-for-this-instance/29074/2 "2021-04-03T17:35:56Z")

</div>

@Kitulous === i dont undestand why you write “each time i want to save a file…” - If the permission was granted once (for externalStorage"); you dont have to ask again… So you can add a method verifying that the permission is already granted, that 's all.
