protected Void doInBackground(Void... params) {
try {
HttpURLConnection http = NetworkUtil.prepare_connection( pref, "add");
- http.setAllowUserInteraction(false);
- http.setRequestProperty("Accept-Charset", "UTF-8");
publishProgress(0);
try(MobileLedgerDatabase dbh = new MobileLedgerDatabase(mContext.get())) {
try(SQLiteDatabase db = dbh.getWritableDatabase()) {
do {
LedgerAccount acc = new LedgerAccount(name);
db.execSQL(
- "insert or replace into accounts(name, name_upper, level, parent_name, keep) "
- + "values(?, ?, ?, ?, 1)",
- new Object[]{name, name.toUpperCase(), acc.getLevel(), acc.getParentName()});
+ "update accounts set level = ?, keep = 1 where name = ?",
+ new Object[]{acc.getLevel(), name});
+ db.execSQL("insert into accounts(name, name_upper, parent_name, level) select ?,?,"
+ + "?,? " + "where (select changes() = 0)",
+ new Object[]{name, name.toUpperCase(), acc.getParentName(), acc.getLevel()});
name = acc.getParentName();
} while (name != null);
}