title: Storing a secret key in Android KeyStore using API 18 and Above
body: <p>Security is not my area of expertise but I have a question regarding storing a secret key in the Android KeyStore using API 18 and above. I use the following code to try and store my key:</p>
  
  <pre><code>KeyStore ks = KeyStore.getInstance("AndroidKeyStore");
  ks.load(null);
  
  KeyStore.SecretKeyEntry sKeyEntry = new KeyStore.SecretKeyEntry(ivKey);
  
  ks.setEntry(ALIAS, sKeyEntry, null); // This is where the issue is
  </code></pre>
  
  <p>I understand that "null" should be a KeyProtection param that I build but this isn't available for API 18. Is there a workaround for this issue? I have been having difficulty finding anything that works.</p>
  
  <p><strong>EDIT</strong> I should mention that leaving it as null throws the error: </p>
  
  <p><code>java.security.KeyStoreException: Protection parameters must be specified when importing a symmetric key</code></p>