8
Tôi có tệp cơ sở dữ liệu nằm trên sdcard và bây giờ khi tệp cơ sở dữ liệu mới được tải xuống, tôi cần ghi đè tệp cũ thay vì đổi tên nó đây là mã tải xuống của tôi. Mã tải xuống hoạt động hoàn hảo ..Làm thế nào tôi có thể làm cho trình quản lý tải xuống ghi đè tệp hiện có thay vì đổi tên tệp trong android
public void startDownload() {
pDialog = new ProgressDialog(this);
pDialog.setMessage("Downloading Database. Please wait...");
pDialog.setIndeterminate(false);
pDialog.setMax(100);
pDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
pDialog.setCancelable(false);
Uri uri=Uri.parse(file_url);
String baseDir = Environment.getExternalStorageDirectory().getAbsolutePath();
File ADirectory = new File(baseDir +"/test");
ADirectory.mkdirs();
lastDownload=
mgr.enqueue(new DownloadManager.Request(uri)
.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI |
DownloadManager.Request.NETWORK_MOBILE)
.setAllowedOverRoaming(false)
.setTitle(" Database File")
.setDescription("Please wait....test Database downloading.")
.setDestinationInExternalPublicDir("/test", "/testing"));
pDialog.show();
//v.setEnabled(false);
// findViewById(R.id.query).setEnabled(true);
}