Another important storage mechanism in android is SDCARD or external storage where apps can store data. Some of the well-known applications store their data in the external storage. Care should be taken while storing data on SDCARD as it's world writable and readable or better yet simply remove the SDCARD from the device. We can then mount it to another device, for us to access and read the data.
Let's use the earlier example and instead of storing it in the internal storage, the application now stores it on the external storage, that is, the SDCARD:
String publicKeyFilename = public.key;
String privateKeyFilename = private.key;
try{
GenerateRSAKeys generateRSAKeys = new GenerateRSAKeys();
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
// Generate public & private keys
KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA", "BC");
...