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 UltraLiteJ runtime tuning values.

Set up the connection profile before the first database access, and check if the database exists by calling the databaseExistsdatabaseExists 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 com.sybase.persistence.ConnectionProfile class to set up the locally generated database:

  1. Retrieve the connection profile object using the Sybase Unwired Platform database's getConnectionProfile method.
  2. Use the connection profile object's save method to set the values once when the application first starts. On subsequent usage of the application, the connection profile will contain all the settings from the last save call.
// Initialize the device database connection profile (if needed)
ConnectionProfile connProfile = SUP101DB.getConnectionProfile();

// Store the database in an SD card
connProfile.setProperty("databaseFile", android.os.Environment.getExternalStorageDirectory().getPath()  "/SUP1011_0.ulj");

// encrypt the database
connProfile.setEncryptionKey("encryption key must be 16 characters or longer");

// use 100K for cache size
connProfile.setCacheSize(102400);

// save it
connProfile.save();

You can also automatically generate a encryption key and store it inside a data vault.

Related reference
ConnectionProfile