app/src/main/java/org/andstatus/app/data/ActorActivity.java
/**
     * Persist the info into the Database
     * @return true if succeeded
     */
Persist the info into the Database
@return true if succeeded
Persist the info into the Database @return true if succeeded
public boolean save() {
        MyLog.v(this, () -> "actorId " + actorId + ": " +
                        MyQuery.actorIdToWebfingerId(myContextHolder.getNow(), actorId)
                + " Latest activity update at " + (new Date(getLastActivityDate()).toString())
                + (changed ? "" : " not changed")
                );
        if (!changed) {
            return true;
        }
        long activityDate = MyQuery.actorIdToLongColumnValue(ActorTable.ACTOR_ACTIVITY_DATE, actorId);
        if (activityDate > lastActivityDate) {
            lastActivityDate = activityDate;
            lastActivityId = MyQuery.actorIdToLongColumnValue(ActorTable.ACTOR_ACTIVITY_ID, actorId);
            MyLog.v(this, () -> "There is newer information in the database. Actor " + actorId + ": "
                    + MyQuery.actorIdToWebfingerId(myContextHolder.getNow(), actorId)
                    + " Latest activity at " + (new Date(getLastActivityDate()).toString()));
            changed = false;
            return true;
        }
        String sql = "";
        try {
            sql += ActorTable.ACTOR_ACTIVITY_ID + "=" + lastActivityId;
            sql += ", " + ActorTable.ACTOR_ACTIVITY_DATE + "=" + lastActivityDate;
            sql = "UPDATE " + ActorTable.TABLE_NAME + " SET " + sql
                    + " WHERE " + BaseColumns._ID + "=" + actorId;
            SQLiteDatabase db = myContextHolder.getNow().getDatabase();
            if (db == null) {
                MyLog.databaseIsNull(() -> "Save " + this);
                return false;
            }
            db.execSQL(sql);
            changed = false;
        } catch (Exception e) {
            MyLog.w(this, "save: sql='" + sql + "'", e);
            return false;
        }
        return true;
    }
public boolean save ( ) { MyLog . v ( this , ( ) -> "actorId " + actorId + ": " + MyQuery . actorIdToWebfingerId ( myContextHolder . getNow ( ) , actorId ) + " Latest activity update at " + ( new Date ( getLastActivityDate ( ) ) . toString ( ) ) + ( changed ? "" : " not changed" ) ) ; if ( ! changed ) { return true ; } long activityDate = MyQuery . actorIdToLongColumnValue ( ActorTable . ACTOR_ACTIVITY_DATE , actorId ) ; if ( activityDate > lastActivityDate ) { lastActivityDate = activityDate ; lastActivityId = MyQuery . actorIdToLongColumnValue ( ActorTable . ACTOR_ACTIVITY_ID , actorId ) ; MyLog . v ( this , ( ) -> "There is newer information in the database. Actor " + actorId + ": " + MyQuery . actorIdToWebfingerId ( myContextHolder . getNow ( ) , actorId ) + " Latest activity at " + ( new Date ( getLastActivityDate ( ) ) . toString ( ) ) ) ; changed = false ; return true ; } String sql = "" ; try { sql += ActorTable . ACTOR_ACTIVITY_ID + "=" + lastActivityId ; sql += ", " + ActorTable . ACTOR_ACTIVITY_DATE + "=" + lastActivityDate ; sql = "UPDATE " + ActorTable . TABLE_NAME + " SET " + sql + " WHERE " + BaseColumns . _ID + "=" + actorId ; SQLiteDatabase db = myContextHolder . getNow ( ) . getDatabase ( ) ; if ( db == null ) { MyLog . databaseIsNull ( ( ) -> "Save " + this ) ; return false ; } db . execSQL ( sql ) ; changed = false ; } catch ( Exception e ) { MyLog . w ( this , "save: sql='" + sql + "'" , e ) ; return false ; } return true ; }
Persist the info into the Database
 @return true if succeeded
Persist the info into the Database @return true if succeeded
// As a precaution compare with stored values ones again