SPFTrigger saveTrigger(SPFTrigger trigger, String appIdentifier) {
    """
	Save the trigger in the database. If the operation succeeds, return a
	trigger with an updated id is returned, otherwise return null. The id is
	updated only when a new trigger is created. ( e.g. its id is set to -1)
	
	@param trigger
	@param appIdentifier
	@return a trigger, otherwise null
    """
		if (appIdentifier == null || trigger == null) {
			throw new NullPointerException();
		}

		ContentValues cv = new ContentValues();
		cv.put(Contract.COLUMN_NAME, trigger.getName());
		cv.put(Contract.COLUMN_QUERY, trigger.getQuery().toQueryString());
		cv.put(Contract.COLUMN_ACTION, trigger.getAction().toJSON());
		cv.put(Contract.COLUMN_ONESHOT, trigger.isOneShot() ? 1 : 0);
		cv.put(Contract.COLUMN_EXPIRATION, trigger.getSleepPeriod());
		cv.put(Contract.COLUMN_APP_IDENTIFIER, appIdentifier);

		SQLiteDatabase db = getWritableDatabase();

		if (trigger.getId() >= 0) {
			String where = Contract._ID + " = ?";
			String[] whereArgs = { String.valueOf(trigger.getId()) };
			if (db.update(Contract.TABLE_NAME, cv, where, whereArgs) > 0) {
				return trigger;
			}
			return null;
		}

		long id = db.insert(Contract.TABLE_NAME, null, cv);
		if (id >= 0) {
			trigger.setId(id);
			return trigger;
		}

		return null;
	}
SPFTrigger saveTrigger(SPFTrigger trigger, String appIdentifier) {
		if (appIdentifier == null || trigger == null) {
			throw new NullPointerException();
		}

		ContentValues cv = new ContentValues();
		cv.put(Contract.COLUMN_NAME, trigger.getName());
		cv.put(Contract.COLUMN_QUERY, trigger.getQuery().toQueryString());
		cv.put(Contract.COLUMN_ACTION, trigger.getAction().toJSON());
		cv.put(Contract.COLUMN_ONESHOT, trigger.isOneShot() ? 1 : 0);
		cv.put(Contract.COLUMN_EXPIRATION, trigger.getSleepPeriod());
		cv.put(Contract.COLUMN_APP_IDENTIFIER, appIdentifier);

		SQLiteDatabase db = getWritableDatabase();

		if (trigger.getId() >= 0) {
			String where = Contract._ID + " = ?";
			String[] whereArgs = { String.valueOf(trigger.getId()) };
			if (db.update(Contract.TABLE_NAME, cv, where, whereArgs) > 0) {
				return trigger;
			}
			return null;
		}

		long id = db.insert(Contract.TABLE_NAME, null, cv);
		if (id >= 0) {
			trigger.setId(id);
			return trigger;
		}

		return null;
	}
SPFTrigger saveTrigger ( SPFTrigger trigger , String appIdentifier ) { if ( appIdentifier == null || trigger == null ) { throw new NullPointerException ( ) ; } ContentValues cv = new ContentValues ( ) ; cv . put ( Contract . COLUMN_NAME , trigger . getName ( ) ) ; cv . put ( Contract . COLUMN_QUERY , trigger . getQuery ( ) . toQueryString ( ) ) ; cv . put ( Contract . COLUMN_ACTION , trigger . getAction ( ) . toJSON ( ) ) ; cv . put ( Contract . COLUMN_ONESHOT , trigger . isOneShot ( ) ? 1 : 0 ) ; cv . put ( Contract . COLUMN_EXPIRATION , trigger . getSleepPeriod ( ) ) ; cv . put ( Contract . COLUMN_APP_IDENTIFIER , appIdentifier ) ; SQLiteDatabase db = getWritableDatabase ( ) ; if ( trigger . getId ( ) >= 0 ) { String where = Contract . _ID + " = ?" ; String [ ] whereArgs = { String . valueOf ( trigger . getId ( ) ) } ; if ( db . update ( Contract . TABLE_NAME , cv , where , whereArgs ) > 0 ) { return trigger ; } return null ; } long id = db . insert ( Contract . TABLE_NAME , null , cv ) ; if ( id >= 0 ) { trigger . setId ( id ) ; return trigger ; } return null ; }
Save the trigger in the database. If the operation succeeds, return a
trigger with an updated id is returned, otherwise return null. The id is
updated only when a new trigger is created. ( e.g. its id is set to -1)

@param trigger
@param appIdentifier
@return a trigger, otherwise null
Save the trigger in the database . If the operation succeeds return a trigger with an updated id is returned otherwise return null . The id is updated only when a new trigger is created . ( e . g . its id is set to - 1 )