我从Firebase下载SQLite数据库。它将保存到设备存储中(Android /数据/包名称/文件/下载)。 我可以将数据库保存到内部目录吗?(例如使用资产文件夹)。我希望没有人在反编译应用程序后可以访问该文件!
private void downloadFileFirebase() {
storageReference = FirebaseStorage.getInstance().getReference();
ref = storageReference.child("test.sqlite");
ref.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
String url = uri.toString();
download(MainActivity.this , "test" ,".sqlite" , DIRECTORY_DOWNLOADS , url );
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
}
});
}
和:
public void download(Context context , String fileName , String fileExtension , String destinationDirectory , String url){
DownloadManager downloadManager = (DownloadManager) context.getSystemService(DOWNLOAD_SERVICE);
Uri uri = Uri.parse(url);
DownloadManager.Request request = new DownloadManager.Request(uri);
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setDestinationInExternalFilesDir(context , destinationDirectory , fileName + fileExtension);
downloadManager.enqueue(request);
}