Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

make Folder in sdcard with password protected: android

Tags:

android

i am saving video and image in a folder ..now i want to make this folder as password protected , means while opening this folder needs to enter a password for view the file inside it
hope here ill get any relevant answer for doing this...if there some any other possible please suggest..

                     try {
                        dirName = "/mydirectory/";
                        fileName = new Long(
                                SystemClock.currentThreadTimeMillis())
                                .toString()
                                + ".png";
                    } catch (NullPointerException e) {
                        // TODO: handle exception
                    }
                    try {
                        if (android.os.Environment
                                .getExternalStorageState()
                                .equals(android.os.Environment.MEDIA_MOUNTED)) {
                            File sdCard = Environment
                                    .getExternalStorageDirectory();
                            File dir = new File(sdCard.getAbsolutePath()
                                    + dirName);
                            dir.mkdirs();

                            File file = new File(storedImagePath);

                            os = new FileOutputStream(file, true);

                            byte[] byteArray = receivedImageData.getBytes();

                            byteArray = Base64.decode(byteArray, 0);

                            os.write(byteArray);
                            os.flush();
                            os.close();

                        } else {

                        }

                    } catch (Exception e) {

                    }
like image 878
SRam Avatar asked May 17 '12 11:05

SRam


People also ask

How do I password protect a folder on my SD card?

Step 1: Open the Settings app and tap Biometrics and Security. Step 2: Scroll down and select Encrypt or on Encrypt SD Card. Step 3: Tap on Encrypt SD Card. Step 4: Enter your Pin, Pattern, or Password and proceed.

How do I create a private folder on my SD card?

Navigate to and open an app with files, such as Gallery. Tap and hold the file(s) you want to move into Secure Folder. Tap More and then tap Move to Secure Folder. The file will be moved and you can view it in Secure Folder.


1 Answers

I'd like to suggest a different/feasible approach, Encrypt your file!

Look at this answer!

Even if you are successful in implementing a password protection (Wow!) here are the cons,

  1. This will only protect when your app is running.
  2. SD cards are supposed to be transferred(Hence your app cannot protect the files on SDcard always).
like image 184
COD3BOY Avatar answered Sep 21 '22 21:09

COD3BOY