How to make your android app ask for superuser access only once?
===

I'm creating my first android app which is changing your MAC address and the device hostname. However, I want to only have to request for superuser access once.

This is how I'm currently executing my su commands:

    String[] cmdHost = { "su", "-c", "/system/bin/setprop net.hostname " + strHostname};
    execute = Runtime.getRuntime().exec(cmdHost);

Every time the user presses on the button to change the hostname or the MAC address, it asks for superuser access again.

Is there any way I can solve this? Also, I see that some apps only execute /system/bin/sh in the SuperUser app logs. Mine shows the whole command.

Thank you very much!