Skip to content

Commit

Permalink
feat: add persistency android
Browse files Browse the repository at this point in the history
  • Loading branch information
riderx committed Nov 23, 2021
1 parent 2dcaf78 commit e89d82d
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package ee.forgr.capacitor_updater;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;

import org.json.JSONException;
Expand All @@ -24,6 +26,8 @@ public class CapacitorUpdater {
private Context context;
private String lastPathHot = "";
private String basePathHot = "versions";
private SharedPreferences prefs;
private SharedPreferences.Editor editor;

static final String AB = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
static SecureRandom rnd = new SecureRandom();
Expand All @@ -37,6 +41,8 @@ private String randomString(int len){

CapacitorUpdater (Context context) {
this.context = context;
this.prefs = context.getSharedPreferences("CapWebViewSettings", Activity.MODE_PRIVATE);
this.editor = prefs.edit();
}

private Boolean unzip(String source, String dest) {
Expand Down Expand Up @@ -177,6 +183,8 @@ public Boolean set(String version) {
Log.i(TAG, "set File : " + destHot.getPath());
if (destHot.exists()) {
lastPathHot = destHot.getPath();
editor.putString("serverBasePath", lastPathHot);
editor.commit();
return true;
}
return false;
Expand Down

0 comments on commit e89d82d

Please sign in to comment.