diff --git a/apps/files_encryption/appinfo/database.xml b/apps/files_encryption/appinfo/database.xml
deleted file mode 100644
index 4587930da0a3c25fb3eecbb4c39afebf9de866ec..0000000000000000000000000000000000000000
--- a/apps/files_encryption/appinfo/database.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1" ?>
-<database>
-	 <name>*dbname*</name>
-	 <create>true</create>
-	 <overwrite>false</overwrite>
-	 <charset>utf8</charset>
-	 <table>
-		<name>*dbprefix*encryption</name>
-		<declaration>
-			<field>
-				<name>uid</name>
-				<type>text</type>
-				<notnull>true</notnull>
-				<length>64</length>
-			</field>
-			<field>
-				<name>mode</name>
-				<type>text</type>
-				<notnull>true</notnull>
-				<length>64</length>
-				<comments>What client-side / server-side configuration is used</comments>
-			</field>
-			<field>
-				<name>recovery_enabled</name>
-				<type>integer</type>
-				<notnull>true</notnull>
-				<default>0</default>
-				<comments>Whether encryption key recovery is enabled</comments>
-			</field>
-			<field>
-				<name>migration_status</name>
-				<type>integer</type>
-				<notnull>true</notnull>
-				<default>0</default>
-				<comments>Whether encryption migration has been performed</comments>
-			</field>
-		</declaration>
-	</table>
-</database>
\ No newline at end of file
diff --git a/apps/files_encryption/appinfo/update.php b/apps/files_encryption/appinfo/update.php
new file mode 100644
index 0000000000000000000000000000000000000000..48262cffa1125a458eaed249b16c6da5f3a2f19d
--- /dev/null
+++ b/apps/files_encryption/appinfo/update.php
@@ -0,0 +1,19 @@
+<?php
+
+$installedVersion=OCP\Config::getAppValue('files_encryption', 'installed_version');
+// migrate settings from oc_encryption to oc_preferences
+if (version_compare($installedVersion, '0.6', '<')) {
+	$sql = 'SELECT * FROM `*PREFIX*encryption`';
+	$query = \OCP\DB::prepare($sql);
+	$result = $query->execute(array())->fetchAll();
+
+	foreach ($result as $row) {
+			\OC_Preferences::setValue($row['uid'], 'files_encryption', 'recovery_enabled', $row['recovery_enabled']);
+			\OC_Preferences::setValue($row['uid'], 'files_encryption', 'migration_status', $row['migration_status']);
+	}
+
+	$deleteOldTable = 'DROP TABLE `*PREFIX*encryption`';
+	$query = \OCP\DB::prepare($deleteOldTable);
+	$query->execute(array());
+
+}
diff --git a/apps/files_encryption/appinfo/version b/apps/files_encryption/appinfo/version
index 2eb3c4fe4eebcdea3da0790cc0ba74cb286ec4f4..5a2a5806df6e909afe3609b5706cb1012913ca0e 100644
--- a/apps/files_encryption/appinfo/version
+++ b/apps/files_encryption/appinfo/version
@@ -1 +1 @@
-0.5
+0.6
diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php
index d1ee4a97d15a3d06105851bff2865a2ad9e76a93..66e2bccd59fda41ab621704b1d3220ae37e5e9ef 100644
--- a/apps/files_encryption/hooks/hooks.php
+++ b/apps/files_encryption/hooks/hooks.php
@@ -530,8 +530,7 @@ class Hooks {
 	public static function preDisable($params) {
 		if ($params['app'] === 'files_encryption') {
 
-			$setMigrationStatus = \OC_DB::prepare('UPDATE `*PREFIX*encryption` SET `migration_status`=0');
-			$setMigrationStatus->execute();
+			\OC_Preferences::deleteAppFromAllUsers('files_encryption');
 
 			$session = new \OCA\Encryption\Session(new \OC\Files\View('/'));
 			$session->setInitialized(\OCA\Encryption\Session::NOT_INITIALIZED);
diff --git a/apps/files_encryption/lib/crypt.php b/apps/files_encryption/lib/crypt.php
index 694791810c9a61f30a7d7a69478f75a17f307ab7..ee2c4024e0952453375bf83c8928bbf70080fa31 100755
--- a/apps/files_encryption/lib/crypt.php
+++ b/apps/files_encryption/lib/crypt.php
@@ -43,6 +43,7 @@ class Crypt {
 	 * return encryption mode client or server side encryption
 	 * @param string $user name (use system wide setting if name=null)
 	 * @return string 'client' or 'server'
+	 * @note at the moment we only support server side encryption
 	 */
 	public static function mode($user = null) {
 
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index 434d23f4a5a48e7873db0d47a3ce408bd09cf5d4..ea2b1b10d63012480eddab947faf9109dea899ea 100644
--- a/apps/files_encryption/lib/util.php
+++ b/apps/files_encryption/lib/util.php
@@ -194,22 +194,6 @@ class Util {
 			}
 		}
 
-		// If there's no record for this user's encryption preferences
-		if (false === $this->recoveryEnabledForUser()) {
-
-			// create database configuration
-			$sql = 'INSERT INTO `*PREFIX*encryption` (`uid`,`mode`,`recovery_enabled`,`migration_status`) VALUES (?,?,?,?)';
-			$args = array(
-				$this->userId,
-				'server-side',
-				0,
-				self::MIGRATION_OPEN
-			);
-			$query = \OCP\DB::prepare($sql);
-			$query->execute($args);
-
-		}
-
 		return true;
 
 	}
@@ -230,36 +214,9 @@ class Util {
 	 */
 	public function recoveryEnabledForUser() {
 
-		$sql = 'SELECT `recovery_enabled` FROM `*PREFIX*encryption` WHERE `uid` = ?';
-
-		$args = array($this->userId);
-
-		$query = \OCP\DB::prepare($sql);
-
-		$result = $query->execute($args);
-
-		$recoveryEnabled = array();
-
-		if (\OCP\DB::isError($result)) {
-			\OCP\Util::writeLog('Encryption library', \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
-		} else {
-			$row = $result->fetchRow();
-			if ($row && isset($row['recovery_enabled'])) {
-				$recoveryEnabled[] = $row['recovery_enabled'];
-			}
-		}
-
-		// If no record is found
-		if (empty($recoveryEnabled)) {
+		$recoveryMode = \OC_Preferences::getValue($this->userId, 'files_encryption', 'recovery_enabled', '0');
 
-			return false;
-
-			// If a record is found
-		} else {
-
-			return $recoveryEnabled[0];
-
-		}
+		return ($recoveryMode === '1') ? true : false;
 
 	}
 
@@ -270,32 +227,8 @@ class Util {
 	 */
 	public function setRecoveryForUser($enabled) {
 
-		$recoveryStatus = $this->recoveryEnabledForUser();
-
-		// If a record for this user already exists, update it
-		if (false === $recoveryStatus) {
-
-			$sql = 'INSERT INTO `*PREFIX*encryption` (`uid`,`mode`,`recovery_enabled`) VALUES (?,?,?)';
-
-			$args = array(
-				$this->userId,
-				'server-side',
-				$enabled
-			);
-
-			// Create a new record instead
-		} else {
-
-			$sql = 'UPDATE `*PREFIX*encryption` SET `recovery_enabled` = ? WHERE `uid` = ?';
-
-			$args = array(
-				$enabled ? '1' : '0',
-				$this->userId
-			);
-
-		}
-
-		return is_numeric(\OC_DB::executeAudited($sql, $args));
+		$value = $enabled ? '1' : '0';
+		return \OC_Preferences::setValue($this->userId, 'files_encryption', 'recovery_enabled', $value);
 
 	}
 
@@ -1133,24 +1066,16 @@ class Util {
 	/**
 	 * set migration status
 	 * @param int $status
+	 * @param int $preCondition only update migration status if the previous value equals $preCondition
 	 * @return boolean
 	 */
-	private function setMigrationStatus($status) {
+	private function setMigrationStatus($status, $preCondition = null) {
 
-		$sql = 'UPDATE `*PREFIX*encryption` SET `migration_status` = ? WHERE `uid` = ?';
-		$args = array($status, $this->userId);
-		$query = \OCP\DB::prepare($sql);
-		$manipulatedRows = $query->execute($args);
+		// convert to string if preCondition is set
+		$preCondition = ($preCondition === null) ? null : (string)$preCondition;
 
-		if ($manipulatedRows === 1) {
-			$result = true;
-			\OCP\Util::writeLog('Encryption library', "Migration status set to " . self::MIGRATION_OPEN, \OCP\Util::INFO);
-		} else {
-			$result = false;
-			\OCP\Util::writeLog('Encryption library', "Could not set migration status to " . self::MIGRATION_OPEN, \OCP\Util::WARN);
-		}
+		return \OC_Preferences::setValue($this->userId, 'files_encryption', 'migration_status', (string)$status, $preCondition);
 
-		return $result;
 	}
 
 	/**
@@ -1159,7 +1084,7 @@ class Util {
 	 */
 	public function beginMigration() {
 
-		$result = $this->setMigrationStatus(self::MIGRATION_IN_PROGRESS);
+		$result = $this->setMigrationStatus(self::MIGRATION_IN_PROGRESS, self::MIGRATION_OPEN);
 
 		if ($result) {
 			\OCP\Util::writeLog('Encryption library', "Start migration to encryption mode for " . $this->userId, \OCP\Util::INFO);
@@ -1199,46 +1124,16 @@ class Util {
 	 */
 	public function getMigrationStatus() {
 
-		$sql = 'SELECT `migration_status` FROM `*PREFIX*encryption` WHERE `uid` = ?';
-
-		$args = array($this->userId);
-		$query = \OCP\DB::prepare($sql);
-
-		$result = $query->execute($args);
-
-		$migrationStatus = array();
-
-		if (\OCP\DB::isError($result)) {
-			\OCP\Util::writeLog('Encryption library', \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
-		} else {
-			$row = $result->fetchRow();
-			if ($row && isset($row['migration_status'])) {
-				$migrationStatus[] = $row['migration_status'];
+		$migrationStatus = false;
+		if (\OCP\User::userExists($this->userId)) {
+			$migrationStatus = \OC_Preferences::getValue($this->userId, 'files_encryption', 'migration_status');
+			if ($migrationStatus === null) {
+				\OC_Preferences::setValue($this->userId, 'files_encryption', 'migration_status', (string)self::MIGRATION_OPEN);
+				$migrationStatus = self::MIGRATION_OPEN;
 			}
 		}
 
-		// If no record is found
-		if (empty($migrationStatus)) {
-			\OCP\Util::writeLog('Encryption library', "Could not get migration status for " . $this->userId . ", no record found", \OCP\Util::ERROR);
-			// insert missing entry in DB with status open if the user exists
-			if (\OCP\User::userExists($this->userId)) {
-				$sql = 'INSERT INTO `*PREFIX*encryption` (`uid`,`mode`,`recovery_enabled`,`migration_status`) VALUES (?,?,?,?)';
-				$args = array(
-					$this->userId,
-					'server-side',
-					0,
-					self::MIGRATION_OPEN
-				);
-				$query = \OCP\DB::prepare($sql);
-				$query->execute($args);
-
-				return self::MIGRATION_OPEN;
-			} else {
-				return false;
-			}
-		} else { // If a record is found
-			return (int)$migrationStatus[0];
-		}
+		return (int)$migrationStatus;
 
 	}
 
diff --git a/apps/files_encryption/templates/settings-personal.php b/apps/files_encryption/templates/settings-personal.php
index 8139ece19505e8bc4e4dd619e8c3beb7a14ad4a2..e9988df327553c5c690d0f6ea2cb78b36d99d8c7 100644
--- a/apps/files_encryption/templates/settings-personal.php
+++ b/apps/files_encryption/templates/settings-personal.php
@@ -46,7 +46,7 @@
 			type='radio'
 			name='userEnableRecovery'
 			value='1'
-			<?php echo ( $_["recoveryEnabledForUser"] == 1 ? 'checked="checked"' : '' ); ?> />
+			<?php echo ( $_["recoveryEnabledForUser"] ? 'checked="checked"' : '' ); ?> />
 			<?php p( $l->t( "Enabled" ) ); ?>
 			<br />
 
@@ -54,7 +54,7 @@
 			type='radio'
 			name='userEnableRecovery'
 			value='0'
-			<?php echo ( $_["recoveryEnabledForUser"] == 0 ? 'checked="checked"' : '' ); ?> />
+			<?php echo ( $_["recoveryEnabledForUser"] === false ? 'checked="checked"' : '' ); ?> />
 			<?php p( $l->t( "Disabled" ) ); ?>
 			<div id="recoveryEnabledSuccess"><?php p( $l->t( 'File recovery settings updated' ) ); ?></div>
 			<div id="recoveryEnabledError"><?php p( $l->t( 'Could not update file recovery' ) ); ?></div>
diff --git a/apps/files_encryption/tests/hooks.php b/apps/files_encryption/tests/hooks.php
index 437034726183fe3665e8a1d356323a5926987420..95f5996bb8e4a6d705f342947c76b7463513378f 100644
--- a/apps/files_encryption/tests/hooks.php
+++ b/apps/files_encryption/tests/hooks.php
@@ -100,6 +100,29 @@ class Test_Encryption_Hooks extends \PHPUnit_Framework_TestCase {
 		\OC_User::deleteUser(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2);
 	}
 
+	function testDisableHook() {
+		// encryption is enabled and running so we should have some user specific
+		// settings in oc_preferences
+		$query = \OC_DB::prepare('SELECT * FROM `*PREFIX*preferences` WHERE `appid` = ?');
+		$result = $query->execute(array('files_encryption'));
+		$row = $result->fetchRow();
+		$this->assertTrue(is_array($row));
+
+		// disabling the app should delete all user specific settings
+		\OCA\Encryption\Hooks::preDisable(array('app' => 'files_encryption'));
+
+		// check if user specific settings for the encryption app are really gone
+		$query = \OC_DB::prepare('SELECT * FROM `*PREFIX*preferences` WHERE `appid` = ?');
+		$result = $query->execute(array('files_encryption'));
+		$row = $result->fetchRow();
+		$this->assertFalse($row);
+
+		// relogin user to initialize the encryption again
+		$user =  \OCP\User::getUser();
+		\Test_Encryption_Util::loginHelper($user);
+
+	}
+
 	function testDeleteHooks() {
 
 		// remember files_trashbin state
diff --git a/apps/files_encryption/tests/util.php b/apps/files_encryption/tests/util.php
index 2b873bb308dfbbcce013e9e73b23b46a4c2e4309..cf2aa5f516ff36cf27a6f32189a34b883a76ddcb 100755
--- a/apps/files_encryption/tests/util.php
+++ b/apps/files_encryption/tests/util.php
@@ -236,16 +236,14 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
 		// Record the value so we can return it to it's original state later
 		$enabled = $util->recoveryEnabledForUser();
 
-		$this->assertTrue($util->setRecoveryForUser(1));
+		$this->assertTrue($util->setRecoveryForUser(!$enabled));
 
-		$this->assertEquals(1, $util->recoveryEnabledForUser());
+		$this->assertEquals(!$enabled, $util->recoveryEnabledForUser());
 
-		$this->assertTrue($util->setRecoveryForUser(0));
+		$this->assertTrue($util->setRecoveryForUser($enabled));
 
-		$this->assertEquals(0, $util->recoveryEnabledForUser());
+		$this->assertEquals($enabled, $util->recoveryEnabledForUser());
 
-		// Return the setting to it's previous state
-		$this->assertTrue($util->setRecoveryForUser($enabled));
 
 	}
 
@@ -587,18 +585,7 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
 	 * @return boolean
 	 */
 	private function setMigrationStatus($status, $user) {
-		$sql = 'UPDATE `*PREFIX*encryption` SET `migration_status` = ? WHERE `uid` = ?';
-		$args = array(
-			$status,
-			$user
-		);
-
-		$query = \OCP\DB::prepare($sql);
-		if ($query->execute($args)) {
-			return true;
-		} else {
-			return false;
-		}
+		return \OC_Preferences::setValue($user, 'files_encryption', 'migration_status', (string)$status);
 	}
 
 }