Code example for PBEKeySpec

		final int iterations = 1000;
		// Generate a 256-bit key 
		final int keyLength = 256;
		final KeySpec spec = new PBEKeySpec(password, salt, iterations,
		return SecurePreferences.encode(SecretKeyFactory 
	private static String generateAesKeyValue() throws NoSuchAlgorithmException {
		// Do *not* seed secureRandom! Automatically seeded from system entropy 
		final SecureRandom random = new SecureRandom();
		// Use the largest AES key length which is supported by the OS 
		final KeyGenerator generator = KeyGenerator.getInstance("AES");
		try { 
			generator.init(256, random);
Connect your IDE to all the code out there  Get Codota for Java