}
return result;
}
+ public static void storeProfilesOrder() {
+ SQLiteDatabase db = MLDB.getWritableDatabase();
+ db.beginTransaction();
+ try {
+ int orderNo = 0;
+ for (MobileLedgerProfile p : Data.profiles.getList()) {
+ db.execSQL("update profiles set order_no=? where uuid=?",
+ new Object[]{orderNo, p.getUuid()});
+ orderNo++;
+ }
+ db.setTransactionSuccessful();
+ }
+ finally {
+ db.endTransaction();
+ }
+ }
public static List<MobileLedgerProfile> createInitialProfileList() {
List<MobileLedgerProfile> result = new ArrayList<>();
MobileLedgerProfile first =
@NonNull RecyclerView.ViewHolder target) {
Collections.swap(Data.profiles.getList(), viewHolder.getAdapterPosition(),
target.getAdapterPosition());
+ MobileLedgerProfile.storeProfilesOrder();
adapter.notifyItemMoved(viewHolder.getAdapterPosition(),
target.getAdapterPosition());
return true;
if ((helperForWriting != helperForReading) && (helperForWriting != null))
helperForWriting.close();
}
+
public enum DatabaseMode {READ, WRITE}
}
class MobileLedgerDatabase extends SQLiteOpenHelper implements AutoCloseable {
public static final String DB_NAME = "mobile-ledger.db";
- public static final int LATEST_REVISION = 15;
+ public static final int LATEST_REVISION = 16;
private final Application mContext;
--- /dev/null
+alter table profiles add order_no integer;
\ No newline at end of file