I am new to Android, and I am trying to encrypt and decrypt a file and want to display in Android device after decrypt.
Here I am downloading the file from the URL and storing in SD card and I don't now how to encrypt the file and then store in SD card and file size may be more then 20MB.
Code:
File downloadFile(String dwnload_file_path) {
    File file = null;
    try {
        String extStorageDirectory = Environment.getExternalStorageDirectory().toString();
        File folder = new File(extStorageDirectory, "SampleFolder");
        folder.mkdir();
        file = new File(folder, dest_file_path);
        try{
            file.createNewFile();
        }catch (IOException e){
            e.printStackTrace();
        }
      
        URL url = new URL(dwnload_file_path);
        HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection();
        urlConnection.connect();
        InputStream inputStream = urlConnection.getInputStream();
        FileOutputStream fileOutputStream = new FileOutputStream(file);
        int totalSize = urlConnection.getContentLength();
        byte[] buffer = new byte[MEGABYTE];
        int bufferLength = 0;
        while((bufferLength = inputStream.read(buffer))>0 ){
            fileOutputStream.write(buffer, 0, bufferLength);
        }
        fileOutputStream.close();
        //ToastManager.toast(this, "Download Complete. Open PDF Application installed in the device.");
    } catch (final MalformedURLException e) {
        //ToastManager.toast(this, "Some error occured. Press try again.");
    } catch (final IOException e) {
        //ToastManager.toast(this, "Some error occured. Press try again.");
    } catch (final Exception e) {
        //ToastManager.toast(this, "Failed to download image. Please check your internet connection.");
    }
    return file;
}
Here I am displaying the file in Android device but after decrypting the file, how can I display it?
Code:
File pdfFile = new File(Environment.getExternalStorageDirectory() + "/SampleFolder/" + "Sample."pref.getString(Constants.PrefConstants.PATH_NAME));
            File f = new File(pdfFile.toString());
            if(f.exists()) {
                    Uri path = Uri.fromFile(pdfFile);
                    Intent pdfIntent = new Intent(Intent.ACTION_VIEW);
                    pdfIntent.setDataAndType(path, pref.getString(Constants.PrefConstants.PATH_NAME_APP));
                    //pdfIntent.setFlags(Intent. FLAG_ACTIVITY_CLEAR_TOP);
                    pdfIntent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
                    startActivity(pdfIntent);
                } else {
                    //uiManager.execute(Constants.Commands.REQGET_INSTRUCTIONS_SCREEN,null);
                    ToastManager.toast(getApplicationContext(), "No data available...");
                }
How can I resolve this issue?
 
     
     
    