How can I backup my database to the sdcard automatically in my app? And afterward, how do I restore it?
1. copy your db to sdcard 2. if reinstall, copy db back to the app. @earthw0rmjim Any approach in which I can get the original state retained without the network.
There is also a button which will show the data from google drive and user can edit and update the data so the updated data is then store in the google drive. I'm new in Android development please help me. you can compress your database file in ZIP and send that zip to server. then send that .
Here is my code:
// Local database
InputStream input = new FileInputStream(from);
// create directory for backup
File dir = new File(DB_BACKUP_PATH);
dir.mkdir();
// Path to the external backup
OutputStream output = new FileOutputStream(to);
// transfer bytes from the Input File to the Output File
byte[] buffer = new byte[1024];
int length;
while ((length = input.read(buffer))>0) {
output.write(buffer, 0, length);
}
output.flush();
output.close();
input.close();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With