title: java.lang.OutOfMemoryError on encrytping a large file in android
body: <p>I am trying to encrypt a 23 MB file using AES algorithm in Android. While the code works when the file size is around 3-4 MB. But when I tested with a 23 MB file it gives me a <code>java.lang.OutOfMemoryError</code></p>
  
  <p>Here is the code-</p>
  
  <pre><code>                 try{
                          SecretKeySpec skey = new SecretKeySpec(Hex.decodeHex(key.toCharArray()), "AES");
                          Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
                          cipher.init(Cipher.ENCRYPT_MODE, skey);
                          output = cipher.doFinal(bFile);
                          String SD_CARD_PATH = Environment.getExternalStorageDirectory().toString();
                          FileOutputStream fileOuputStream = new FileOutputStream(SD_CARD_PATH+ "/" + "abcd.db"); 
                          fileOuputStream.write(output);
                          fileOuputStream.close();
                          //System.out.println(output);
                      }catch(Exception e){
                          System.out.println("Error: "+e);
                      }
  </code></pre>
  
  <p>I get this error in the line- <code>output = cipher.doFinal(bFile);</code> 
  Is there any other way to do this? What should I do?</p>