How to secure prefilled database after coping to sandbox in xamarin.android?


#1

Hi All,

I am working on Xamarin.Forms app within that I have integrated Sql Cipher on platform dependent . Now I want to secure my prefilled db . using following code

public void EncrptSqliteDb(string source, string destination, string password)
{

		SqliteConnection connection = new SqliteConnection (string.Format("Data Source={0}", source));
		connection.Open();
		using (var cmd = connection.CreateCommand())
		{
			cmd.CommandText = string.Format("ATTACH DATABASE '{0}' AS encrypted KEY '{1}'", destination, password);

			cmd.CommandText = "SELECT sqlcipher_export('encrypted')";

			cmd.CommandText = "DETACH DATABASE encrypted";


		}
		connection.Close ();
    
	
}

#2

Hello @DnyaneshwarPM

You will need to execute each command before you reset the CommandText. Could you give that a try?