Code example for KeyStore

Methods: store

0
    } 
 
    private synchronized void store() { 
        try { 
            FileOutputStream fos = mContext.openFileOutput(KEYSTORE_FILENAME, Context.MODE_PRIVATE);
            mKeyStore.store(fos, KEYSTORE_PASSWORD);
            fos.close();
        } catch (IOException e) {
            throw new IllegalStateException("Unable to store keyStore", e);
        } catch (GeneralSecurityException e) {
            throw new IllegalStateException("Unable to store keyStore", e);
        } 
    } 
 
    /** 
     * Returns the name that should be used in a new certificate. 
     * <p> 
     * The format is: "CN=anymote/PRODUCT/DEVICE/MODEL/unique identifier" 
     */ 
    private static final String getCertificateName(String id) {
        return "CN=anymote/" + Build.PRODUCT + "/" + Build.DEVICE + "/" + Build.MODEL + "/" + id;