Android examples for java.security:KeyStore
has Key in KeyStore
//package com.java2s; import java.io.IOException; import java.security.KeyStore; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.cert.CertificateException; public class Main { public static final String KEY_STORE_TYPE = "AndroidKeyStore"; public static boolean hasKey(String alias) { try {//from w ww .j a v a 2 s. c o m KeyStore keyStore = KeyStore.getInstance(KEY_STORE_TYPE); keyStore.load(null); return keyStore.containsAlias(alias) && keyStore.isKeyEntry(alias); } catch (KeyStoreException | CertificateException | IOException | NoSuchAlgorithmException e) { e.printStackTrace(); } return false; } }