I m using Firebase as my primary database, some of the local data is storing into sqlite. I m trying to backup and restore my sqlite db file from local storage to Firebase Storage... I have uploaded the file and now i want to restore it into the same package/databases directory... but couldn't figure it out.
// uploading SQLITE.DB file to FIREBASE STORAGE
@SuppressLint("SdCardPath") String inFileName = "/data/data/com.example.casebook/databases/EVENTS_DB.db";
Uri localDB = Uri.fromFile(new File(inFileName));
final StorageReference DBRef = storageReference.child("users/"+fAuth.getCurrentUser().getUid()+"/EVENTS_DB.csv");
DBRef.putFile(localDB).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
Toast.makeText(getApplicationContext(), "FILE UPLOADED", Toast.LENGTH_SHORT).show();
}
});
// downloading SQLITE.db file from FIREBASE STORAGE
DBRef.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
// here i want to get the "EVENTS_DB.db" file to the exact same path "inFileName" for restoring the same DB with help of FIREBASE STORAGE.
}
});