Using SQLCipher with SmartStore

Starting in Mobile SDK 13.0, SmartStore supports SQLCipher Commercial, Enterprise, and Enterprise FIPS.

Set Up Your SQLCipher Edition on iOS 

To set up SQLCipher Commercial, Enterprise, or Enterprise FIPS, follow these steps.

  1. In SQLCipher’s documentation, find your SQLCipher edition of choice, and then download the corresponding package.
  2. Find SQLCipher.xcframework and openssl.xcframework in the package you downloaded, and then add them to your application target.
  3. Pass the license key to SmartStore during application initialization, prior to any SmartStore operations. To specify the license key for your app, use this method from SFSmartStore.h.
1// @param licenseKey - The license key string provided by Zetetic.
2+ (void)setLicenseKey:(NSString*)licenseKey;
  1. Call SmartStore.setLicenseKey("LICENSE_KEY_STRING") from the AppDelegate class when the app finishes launching.
1func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
2    SmartStore.setLicenseKey("LICENSE_KEY_STRING")
3    ...
4}

Set Up Your SQLCipher Edition on Android 

To set up SQLCipher Commercial, Enterprise, or Enterprise FIPS, follow these steps.

  1. In SQLCipher’s documentation, find your SQLCipher edition of choice, and then download the corresponding package.
  2. Create a libs folder in the app directory.
  3. Find SQLCipher.aar from the package you downloaded, and add it to the libs folder.
  4. Pass the license key to SmartStore during application initialization, before any SmartStore operations. To specify the license key for your app, use this method from SmartStore.java.
1// @param licenseKey - The license key string provided by Zetetic.
2+ public static void setLicenseKey(String licenseKey)
  1. Call SmartStore.setLicenseKey("LICENSE_KEY_STRING") from the Application subclass before initializing SalesforceSDKManager.
1class MainApplication : Application() {
2    override fun onCreate() {
3        super.onCreate()
4        appContext = applicationContext
5        SmartStore.setLicenseKey("LICENSE_KEY_STRING")
6        MobileSyncSDKManager.initNative(this, ContactsActivity::class.java)
7    }
8    ...
9}

Check the SQLCipher Status 

To check the SQLCipher’s version, provider version, compile options, and FIPS status, use these methods.

iOS 

Find these methods in SFSmartStore.h.

1/**
2* Return SQLCipher compile options
3* @return An array with all the compile options used to build SQL Cipher.
4*/
5- (NSArray *)getCompileOptions NS_SWIFT_NAME(compileOptions());
6
7/**
8* Return SQLCipher version
9* @return The version of SQL Cipher in use.
10*/
11- (NSString *)getSQLCipherVersion NS_SWIFT_NAME(versionOfSQLCipher());
12
13/**
14* Return SQLCipher provider version
15* @return cipher provider version
16*/
17- (NSString *)getCipherProviderVersion NS_SWIFT_NAME(cipherProviderVersion());
18
19/**
20* Return SQLCipher FIPS status
21* @return true if using a FIPS enabled SQLCipher edition
22*/
23- (BOOL)getCipherFIPSStatus NS_SWIFT_NAME(cipherFIPSStatus());

Android 

Find these methods in SmartStore.java.

1/**
2* Get SQLCipher version
3*
4* @return SQLCipher version
5*/
6public String getSQLCipherVersion()
7
8/**
9* Get SQLCipher provider version
10*
11* @return SQLCipher provider version
12*/
13public String getCipherProviderVersion()
14
15/**
16* Get SQLCipher FIPS status
17*
18* @return true if using a FIPS enabled SQLCipher edition
19*/
20public boolean getCipherFIPSStatus()
21
22+ public static void setLicenseKey(String licenseKey)

We've Moved

Welcome to the new home of the Mobile SDK Developer Guide! For now, the Japanese guide can be found in PDF form.