0
내 응용 프로그램에서는 데이터베이스 파일을 sdcard에 복사하여 데이터베이스를 내보낼 수있는 기능을 구현했습니다. 파일을 암호화하지 않거나 특수 키가 필요하므로 파일을 선택하는 사람이 sqlite 파일 판독기에서 열어 db 구조 또는 데이터를 읽을 수 있는지 확인하고자합니다.내 보낸 데이터베이스에 대한 조명 보호
내 파일을 간단하고 간단하게 보호하려면 어떻게해야합니까?
다음은 db 내보내기를위한 코드입니다.
public void exportDB() {
final String destFolder = "/"+Constants.Files.APP_FOLDER+"/"+Constants.Files.BACKUP_FOLDER;
try {
File myBackupDir = new File(Environment.getExternalStorageDirectory() + destFolder);
if(!myBackupDir.exists() || !myBackupDir.isDirectory()) myBackupDir.mkdirs();
if(myBackupDir.isDirectory()){
File data = Environment.getDataDirectory();
if (Environment.getExternalStorageDirectory().canWrite()) {
final String currentDBPath= "//data//" + Constants.Files.PACKAGE_NAME + "//databases//" + Constants.Files.DB_NAME;
File currentDB = new File(data, currentDBPath);
File backupDB = new File(myBackupDir, Constants.Files.DB_NAME);
if(currentDB.isFile()){
copyFile(new FileInputStream(currentDB), new FileOutputStream(backupDB))
}
}
}
} catch (Exception e) {
Log.e(mTag, "exportDB", e);
}
}
public static void copyFile(FileInputStream fromFile, FileOutputStream toFile) throws IOException {
FileChannel fromChannel = null;
FileChannel toChannel = null;
try {
fromChannel = fromFile.getChannel();
toChannel = toFile.getChannel();
fromChannel.transferTo(0, fromChannel.size(), toChannel);
} finally {
try {
if (fromChannel != null) {
fromChannel.close();
}
} finally {
if (toChannel != null) {
toChannel.close();
}
}
}
}
이것은 사용자의 데이터가 아니라 사용자의 데이터입니다. 사용자가 사용자의 데이터로 원하는 것을 할 수있게하십시오. – CommonsWare