Creating and Deleting a Device's Local Database

There are methods in the generated package database class that allow programmers to delete or create a device's local database. A device local database is automatically created when needed by the Object API. The application can also create the database programatically by calling the createDatabase method. The device's local database should be deleted when uninstalling the application.

Check if the locally generated database exists, create the database, or delete the database:

  1. Check if an instance of the generated database exists by calling the generated database instance's databaseExists method.
  2. If an instance of a the generated database does not exist, call the generated database instance's createDatabase method.
    if (!SUP101DB.databaseExists())
        {
            SUP101DB.createDatabase();
        }
  3. Connect to the generated database by calling the generated database instance's openConnection method.
    SUP101DB.openConnection();
    If the database does not already exist, the openConnection method creates it.
  4. When the local database is no longer needed, delete it by calling the generated database instance's deleteDatabase method.
    SUP101DB.deleteDatabase();