使文件夹在SD卡与密码保护:机器人 [英] make Folder in sdcard with password protected: android

查看:166
本文介绍了使文件夹在SD卡与密码保护:机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我节省了视频和图像文件夹中..now我想使这个文件夹密码保护,意味着同时打开此文件夹需要输入密码查看里面的文件
     希望在这里生病得到任何相关答案这样做......如果有一些其他可能请建议..

 尝试{
                        目录名称=/ mydirectory /
                        文件名=新龙(
                                SystemClock.currentThreadTimeMillis())
                                的ToString()
                                +的.png;
                    }赶上(NullPointerException异常E){
                        // TODO:处理异常
                    }
                    尝试 {
                        如果(android.os.Environment
                                .getExternalStorageState()
                                .equals(android.os.Environment.MEDIA_MOUNTED)){
                            文件SD卡=环境
                                    .getExternalStorageDirectory();
                            文件DIR =新的文件(sdCard.getAbsolutePath()
                                    +目录名);
                            dir.mkdirs();

                            档案文件=新的文件(storedImagePath);

                            OS =新的FileOutputStream(文件,真正的);

                            字节[]的字节数组= receivedImageData.getBytes();

                            的字节数组= Base64.de code(字节数组,0);

                            os.write(字节阵列);
                            os.flush();
                            os.close();

                        } 其他 {

                        }

                    }赶上(例外五){

                    }
 

解决方案

我想提出一个不同的/可行的办法,加密你的文件

这个答案!

即使你成功地实施密码保护(哇!)这里有利弊,

  1. 这将只有当你的应用程序正在运行保障。
  2. 在SD卡都应该被转移(因此你的应用程序无法保障在SD卡中的文件总是)。

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) {

                    }

解决方案

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).

这篇关于使文件夹在SD卡与密码保护:机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆