简体   繁体   中英

I want to use Android KeyChain to store public key and private key

I want to store private key in android KeyChain. I write code to store key already. But I don't understand when uninstall app and clear app key lost or not. I want to store key in KeyChain when clear app or uninstall key still have.

try {
        Intent intent = KeyChain.createInstallIntent();
        intent.putExtra("PKEY", privateKey);
        intent.putExtra("KEY", publicKey);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
        return true;
    } catch (ActivityNotFoundException e) {
        Log.w("MainActivity", "could not store key pair: " + e);
    }

How can I retrieve private key from KeyChain.createInstallIntent()?

Intent stores data for only for some limited time.If you want to store key value data permanently I suggest to use Json Api.You have to create json API using PHP & manage your data by calling APi when you need in your android App.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM