【发布时间】:2020-05-28 14:28:52
【问题描述】:
所以,这个程序从 firebase 存储下载一个文件, 我的下载代码是:
private void downloadFiles(Context context, String fileName, String destinationDirectory, String url) {
DownloadManager downloadManager = (DownloadManager) context.getSystemService(Context.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, String.valueOf(destinationDirectory), fileName);
downloadManager.enqueue(request);
}
public void downloading(final String name) {
downloadRef = storage.getInstance().getReference().child(name);
downloadRef.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
String url = uri.toString();
downloadFiles(Main2Activity.this, name, getApplicationContext().getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS), url);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(Main2Activity.this, "Failed!!!", Toast.LENGTH_LONG).show();
}
});
}
然后我想使用这个数据库,所以我尝试打开它:
database = SQLiteDatabase.openDatabase(myPath, null, 0);
我该如何解决这个问题?这对伙计们很有帮助。
【问题讨论】:
标签: java android firebase firebase-storage