public boolean openFile(String path, long fileLength)
	{
		File outputFile = new File(path);
		
		if (outputFile.exists())
		{
            Log.i(LOG_TAG, "Deleting existing file " + path);
			outputFile.delete();
		}
		
		try
		{
			outputFile.createNewFile();
		}
		catch (IOException e)
		{
            Log.e(LOG_TAG, "Error creating output file - " + e.getMessage());
			
			return false;
		}
		
		byte [] encryptionKey = securityManager.generateRandomKey();
		byte [] randomSalt = securityManager.generateRandomKey();
		
		byte [] saltedEncryptionKey = new byte [encryptionKey.length + randomSalt.length];
		System.arraycopy(randomSalt, 0, saltedEncryptionKey, 0, randomSalt.length);
		System.arraycopy(encryptionKey, 0, saltedEncryptionKey, randomSalt.length, encryptionKey.length);
		
		byte [] encryptedSaltedEncryptionKey = securityManager.encryptWithDeviceKey(saltedEncryptionKey);
		
		//set up header		
		EncryptedFileHeader header = new EncryptedFileHeader();

		System.arraycopy(ENCRYPTED_FILE_EXTENSION.getBytes(), 0, header.magicBytes, 0, header.magicBytes.length);
		header.headerVersion = 1;
		header.headerLength = EncryptedFileHeader.ENCRYPTED_FILE_HEADER_LENGTH;
		header.fileLength = fileLength;
		header.chunkSizeInKB = DEFAULT_CHUNK_SIZE_IN_BYTES / 1024;
		chunkSizeInBytes = DEFAULT_CHUNK_SIZE_IN_BYTES;

		System.arraycopy(randomSalt, 0, header.salt, 0, header.salt.length);
		System.arraycopy(encryptedSaltedEncryptionKey, 0, header.saltedEncryptedKey, 0, header.saltedEncryptedKey.length);

		initialisationVector = securityManager.generateRandomKey();
		
		System.arraycopy(initialisationVector, 0, header.iv, 0, header.iv.length);
		
		try
		{
			outputStream = new BufferedOutputStream( new FileOutputStream(outputFile));
			outputStream.write(header.toBytes());
		}
		catch (Exception e)
		{
            Log.e(LOG_TAG, "Error writing file header - " + e.getMessage());
			
			return false;
		}
		
		currentChunk = new byte [chunkSizeInBytes];
		encryptedChunk = new byte [chunkSizeInBytes];
		
		try
		{
			Key cipherKey = new SecretKeySpec(encryptionKey, 0, SecurityManager.ENCRYPTION_KEY_LENGTH, "AES");
			aesCipher = Cipher.getInstance("AES/CBC/NOPADDING");
			aesCipher.init(Cipher.ENCRYPT_MODE, cipherKey, new IvParameterSpec(initialisationVector));
		}
		catch (Exception e)
		{
            Log.e(LOG_TAG, "Error initialising encryptor - " + e.getClass().getName() + " : " + e.getMessage());
			
			return false;
		}
		
		return true;
	}