diff --git a/lib/appconfig.php b/lib/appconfig.php
index 06281d385856695f057e0ad794367c6e14926a75..c64a15b8938812bfd256fcd4056c5c8b1746e87a 100644
--- a/lib/appconfig.php
+++ b/lib/appconfig.php
@@ -114,10 +114,10 @@ class OC_Appconfig{
 	 */
 	public static function setValue( $app, $key, $value ){
 		// Does the key exist? yes: update. No: insert
-		$exists = self::getValue( $app, $key, null );
+		$exists = self::getKeys( $app );
 
 		// null: does not exist
-		if( is_null( $exists )){
+		if( !in_array( $key, $exists )){
 			$query = OC_DB::prepare( 'INSERT INTO *PREFIX*appconfig ( appid, configkey, configvalue ) VALUES( ?, ?, ? )' );
 			$query->execute( array( $app, $key, $value ));
 		}