aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/ui/UpdaterActivity.java
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2016-08-08 22:04:57 +0200
committerChristian Schneppe <christian@pix-art.de>2016-08-09 22:34:03 +0200
commitbb4c255314e0beb1713050cc231f317894997f53 (patch)
tree97a413d8b0db8759d8876ac2ee0ce9b56dff5f3e /src/main/java/de/pixart/messenger/ui/UpdaterActivity.java
parent7dd493bff1ddfb0f12d95a6ed466f42973e09051 (diff)
reworked backup service
* automatically save database encrypted to local storage at 4 am each day * run backup import in new thread
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui/UpdaterActivity.java')
-rw-r--r--src/main/java/de/pixart/messenger/ui/UpdaterActivity.java45
1 files changed, 3 insertions, 42 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/UpdaterActivity.java b/src/main/java/de/pixart/messenger/ui/UpdaterActivity.java
index 0a35288d7..fcd4275a4 100644
--- a/src/main/java/de/pixart/messenger/ui/UpdaterActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/UpdaterActivity.java
@@ -26,15 +26,10 @@ import org.json.JSONException;
import org.json.JSONObject;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
import de.pixart.messenger.Config;
import de.pixart.messenger.R;
-import de.pixart.messenger.persistance.DatabaseBackend;
+import de.pixart.messenger.services.ExportLogsService;
import de.pixart.messenger.services.UpdaterWebService;
public class UpdaterActivity extends Activity {
@@ -62,7 +57,6 @@ public class UpdaterActivity extends Activity {
installIntent.putExtra(Intent.EXTRA_RETURN_RESULT, true);
installIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(installIntent);
-
UpdaterActivity.this.finish();
}
}
@@ -99,36 +93,6 @@ public class UpdaterActivity extends Activity {
}
}
- private void ExportDatabase() throws IOException {
-
- // Get hold of the db:
- InputStream myInput = new FileInputStream(this.getDatabasePath(DatabaseBackend.DATABASE_NAME));
-
- // Set the output folder on the SDcard
- File directory = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pix-Art Messenger/.Database/");
-
- // Create the folder if it doesn't exist:
- if (!directory.exists()) {
- directory.mkdirs();
- }
-
- // Set the output file stream up:
- OutputStream myOutput = new FileOutputStream(directory.getPath() + "/Database.bak");
-
- // Transfer bytes from the input file to the output file
- byte[] buffer = new byte[1024];
- int length;
- while ((length = myInput.read(buffer)) > 0) {
- myOutput.write(buffer, 0, length);
- }
-
- // Close and clear the streams
- myOutput.flush();
- myOutput.close();
- myInput.close();
- }
-
-
@Override
public void onDestroy() {
//unregister your receivers
@@ -230,11 +194,8 @@ public class UpdaterActivity extends Activity {
if (success) {
if (isStoragePermissionGranted()) {
//start backing up database
- try {
- ExportDatabase();
- } catch (IOException e) {
- e.printStackTrace();
- }
+ final Intent startIntent = new Intent(getBaseContext(), ExportLogsService.class);
+ getBaseContext().startService(startIntent);
}
//Overall information about the contents of a package
//This corresponds to all of the information collected from AndroidManifest.xml.