Setting Up the Connection Profile

The Connection Profile stores information detailing where and how the local database is stored, including location and page size. The connection profile also contains UltraLite®J runtime tuning values.

Set up the connection profile before the first database access, and check if the database exists by calling the DatabaseExists method in the generated package database class. Any settings you establish after the connection has already been established will not go into effect.

The generated database class automatically contains all the default settings for the connection profile. You may add other settings if necessary. For example, you can set the database to be stored in an SD card or set the encryption key of the database.

Use the Sybase.Persistence.ConnectionProfile class to set up the locally generated database. Retrieve the connection profile object using the SAP Mobile Platform database's GetConnectionProfile method.

// Initialize the device database connection profile (if needed)
ConnectionProfile connProfile = SMP101DB.GetConnectionProfile();

// encrypt the database
connProfile.SetEncryptionKey("your encryption key"); //Encryption key can be of arbitary length, but generally the longer, the better.
// You can also automatically generate a encryption key and store it inside a data vault.

// use 100K for cache size
connProfile.CacheSize = 102400;

// Store the database in a location other than the default location
connProfile.SetProperty("databaseFile", "SMP1011_0.udb"); 

An application can have multiple threads writing to the database during synchronization by enabling the connection profile property, allowConcurrentWrite. Setting the property to "true" allows multiple threads to perform create, read, update, or delete operations at the same time in a package database. For example:

SMP101DB.GetConnectionProfile().SetProperty("allowConcurrentWrite", "true"); 
Note: Multiple threads are allowed to write to the database at the same time. However, there will be errors when multiple threads write to the same row of one MBO. Avoid writing to the same MBO row in your application.
Related reference
ConnectionProfile