Is it possible to have interaction when updating my app?

Asked

Viewed 46 times

1

How can I change sharedPreferences or add a folder at the time of my app update?

I have a C app that I’m running on Android with the SDL library and every time I update the app the application files have to be updated too (they’re in a system folder). The problem is I don’t know when an update was made.

I know that by booting the app I can do this, but it’s still a scam and there may be problems if the user doesn’t open the app until the next update. If there was a way to do it during installation it was ideal and solved all problems.

  • Make a check whenever the application opens, if the folder exists leave as it is, if it does not exist, create.

1 answer

2


Is not possible.

You will have to wait the next time the application is executed and then do so.

The only chance is to have, in another package, one Broadcastreceiver to respond to Intents ACTION_PACKAGE_ADDED and ACTION_PACKAGE_CHANGED and run an installed/updated application service updating those files.

The method onReceive() of Bradcastreceiver it would be something like that:

public void onReceive(Context context, Intent intent) {
    final String action = intent.getAction();

    if (action.equals(Intent.ACTION_PACKAGE_ADDED)) {
        Uri data = intent.getData();
        String pkgName = data.getEncodedSchemeSpecificPart();
        if(pkgName.equals("nome da package"){
            //Executar serviço para terminar a instalação
        }
    }

    //Testar intent ACTION_PACKAGE_CHANGED
    ....
    ....
}

The problem is whether this package is uninstalled....

  • 1

    If there’s no answer I’ll mark yours.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.