insert or update
This commit is contained in:
parent
5f02561f9d
commit
f153600dd1
|
@ -149,16 +149,14 @@ public class BackupUtils {
|
||||||
try {
|
try {
|
||||||
JSONObject savedValues = new JSONObject(jString);
|
JSONObject savedValues = new JSONObject(jString);
|
||||||
ContentValues fields = new ContentValues();
|
ContentValues fields = new ContentValues();
|
||||||
|
int port = savedValues.getInt(HSContentProvider.HiddenService.PORT);
|
||||||
|
|
||||||
fields.put(
|
fields.put(
|
||||||
HSContentProvider.HiddenService.NAME,
|
HSContentProvider.HiddenService.NAME,
|
||||||
savedValues.getString(HSContentProvider.HiddenService.NAME)
|
savedValues.getString(HSContentProvider.HiddenService.NAME)
|
||||||
);
|
);
|
||||||
|
|
||||||
fields.put(
|
fields.put(HSContentProvider.HiddenService.PORT, port);
|
||||||
HSContentProvider.HiddenService.PORT,
|
|
||||||
savedValues.getInt(HSContentProvider.HiddenService.PORT)
|
|
||||||
);
|
|
||||||
|
|
||||||
fields.put(
|
fields.put(
|
||||||
HSContentProvider.HiddenService.ONION_PORT,
|
HSContentProvider.HiddenService.ONION_PORT,
|
||||||
|
@ -175,7 +173,27 @@ public class BackupUtils {
|
||||||
savedValues.getInt(HSContentProvider.HiddenService.CREATED_BY_USER)
|
savedValues.getInt(HSContentProvider.HiddenService.CREATED_BY_USER)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Cursor service = mResolver.query(
|
||||||
|
HSContentProvider.CONTENT_URI,
|
||||||
|
HSContentProvider.PROJECTION,
|
||||||
|
HSContentProvider.HiddenService.PORT + "=" + port,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
if (service.getCount() == 0) {
|
||||||
mResolver.insert(HSContentProvider.CONTENT_URI, fields);
|
mResolver.insert(HSContentProvider.CONTENT_URI, fields);
|
||||||
|
} else {
|
||||||
|
mResolver.update(
|
||||||
|
HSContentProvider.CONTENT_URI,
|
||||||
|
fields,
|
||||||
|
HSContentProvider.HiddenService.PORT + "=" + port,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
service.close();
|
||||||
|
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Toast.makeText(mContext, R.string.error, Toast.LENGTH_LONG).show();
|
Toast.makeText(mContext, R.string.error, Toast.LENGTH_LONG).show();
|
||||||
|
|
Loading…
Reference in New Issue