Examples of PersistentObject


Examples of net.rim.device.api.system.PersistentObject

        try {
            // Generate store key for this app.
            _storeKey = generateStoreKeyFromPackageName();

            // Check Persistent Store for existing cacheTable data.
            PersistentObject cacheTableStore = PersistentStore.getPersistentObject( _storeKey );

            // Get the code signing key associated with this BlackBerry WebWorks Application.
            CodeSigningKey codeSigningKey = CodeSigningKey.get( this );
            Object cacheTableObj = cacheTableStore.getContents( codeSigningKey );

            // If we find an entry in the Persistent store.
            if( cacheTableObj != null ) {

                if( cacheTableObj instanceof Hashtable ) {
                    // Set the cache table using the stored value.
                    _cacheTable = (Hashtable) cacheTableObj;

                    // Ensure that expired entries are cleaned out.
                    cleanExpiredCache();
                }
            }
            // Otherwise, create the cacheTable entry in persistent store.
            else {
                synchronized( cacheTableStore ) {
                    cacheTableStore.setContents( new ControlledAccess( _cacheTable, codeSigningKey ) );
                    cacheTableStore.commit();
                }
            }

        } catch( Exception e ) {
        }
View Full Code Here

Examples of net.rim.device.api.system.PersistentObject

     */
//     * <li><b>A positive number</b>, representing the number of parameters
//     *     wrong, if the store does not contain one or more values.
//     *     The missing params maintain the current value.
    public static int load() {
        PersistentObject pobj = PersistentStore.getPersistentObject(SyncClient.CONFIG_KEY);
       
        try {
            ConfigData contents = (ConfigData)pobj.getContents();
   
            if (contents == null) {
                Log.info("Configuration not set, using current values.");
                return -1;
            }
View Full Code Here

Examples of net.rim.device.api.system.PersistentObject

    /**
     * Save the current config to the persistent store.
     */
    public static int save() {
        PersistentObject pobj = PersistentStore.getPersistentObject(SyncClient.CONFIG_KEY);
       
        ConfigData contents = new ConfigData();

        // This field can be used to check which version of the sw
        // saved the data. If not present, it is assumed it's an
        // old version and the saved config is discarded.
        contents.setValue("VERSION", VERSION);
       
        contents.setValue("SYNC_URL", syncUrl);
        contents.setValue("USERNAME", userName);
        contents.setValue("PASSWORD", password);
       
        contents.setValue("SYNC_CARD", syncContact);
        contents.setValue("CARD_URI", contactSourceUri);
       
        contents.setValue("SYNC_CAL", syncCalendar);
        contents.setValue("CAL_URI", calendarSourceUri);
       
        contents.setValue("SYNC_MAIL", syncMail) ;
        contents.setValue("MAIL_URI", mailSourceUri) ;
        contents.setValue("MAIL_ADDR", mailAddress) ;
        contents.setValue("POLL_ENABLE", enablePolling) ;
        contents.setValue("POLL_TIME", pollInterval) ;
        contents.setValue("SMS_ENABLE", enableSmsSync) ;
       
        contents.setValue("GW_APN", gatewayApn) ;
        contents.setValue("GW_IP", gatewayIp) ;
        contents.setValue("GW_PORT", gatewayPort) ;
        contents.setValue("PUSH_PORT", listeningPort) ;

        contents.setValue("log_LEVEL", logLevel) ;
       
        synchronized (pobj) {
            pobj.setContents(contents);
            pobj.commit();
        }

        return 0;
    }
View Full Code Here

Examples of net.rim.device.api.system.PersistentObject

       
    }
   
    private static void loadSettings() {
        synchronized(PersistentStore.getSynchObject()) {
            PersistentObject po = PersistentStore.getPersistentObject(SETTINGS_ID);
            Object obj = po.getContents();
            if (obj != null) {
                _settings = (Settings) obj;
            } else {
                _settings.setISO14443A(false);
                _settings.setISO14443B(true);
View Full Code Here

Examples of net.rim.device.api.system.PersistentObject

    }
   
    public void saveSettings() {
        Utilities.log("XXXX " + Thread.currentThread().getName() + " Saving settings");
        synchronized(PersistentStore.getSynchObject()) {
            PersistentObject po = PersistentStore.getPersistentObject(SETTINGS_ID);
            po.setContents(_settings);
            po.commit();
            Utilities.log("XXXX " + Thread.currentThread().getName() + " Saved settings:" + _settings.toString());
        }
    }
View Full Code Here

Examples of net.rim.device.api.system.PersistentObject

            public void execute(final ReadOnlyCommandMetadata metadata,
                    final Object context) {
                // Attempt to gain access to the controlled object. If
                // the module has been signed with the ACME private key,
                // the attempt will succeed.
                final PersistentObject controlledStore =
                        PersistentStore
                                .getPersistentObject(PersistentStoreDemo.PERSISTENT_STORE_DEMO_CONTROLLED_ID);
                if (controlledStore != null) {
                    try {
                        final Vector vector =
                                (Vector) controlledStore.getContents();
                        if (vector != null) {
                            Dialog.alert("Successfully accessed controlled object");
                        }
                    } catch (final SecurityException se) {
                        UiApplication.getUiApplication().invokeLater(
View Full Code Here

Examples of net.rim.device.api.system.PersistentObject

            // Take care of any in memory data first
            ((BlackBerryBalanceDemo) uiApp).onWipe(serviceUid, dataType);
        }

        // Retrieve the persistent object for this application
        final PersistentObject store =
                PersistentStore
                        .getPersistentObject(BlackBerryBalanceDemo.BLACKBERRY_BALANCE_DEMO_ID);

        // Retrieve the saved Memo objects from the persistent store
        final Vector memos = (Vector) store.getContents();

        final int size = memos.size();

        for (int i = 0; i < size; ++i) {
            final Memo memo = (Memo) memos.elementAt(i);

            if (serviceUid.equals(memo.getMode())) {
                // Wipe the memo
                memos.removeElementAt(i);
            }
        }

        synchronized (store) {
            // Persist the updated collection
            store.setContents(memos);
            PersistentObject.commit(store);
        }

        return MultiServicePlatformConstants.SUCCESS;
    }
View Full Code Here

Examples of net.rim.device.api.system.PersistentObject

        // even if the device locks during the re-encoding operation.
        final Object ticket = PersistentContent.getTicket();

        if (ticket != null) {

            final PersistentObject store =
                    PersistentStore
                            .getPersistentObject(BlackBerryBalanceDemo.BLACKBERRY_BALANCE_DEMO_ID);

            if (store != null) {
                synchronized (store) {
                    final Vector memos = (Vector) store.getContents();
                    if (memos == null) {
                        // Contents empty; nothing to re-encode
                        return;
                    }
                    for (int i = 0; i < memos.size(); ++i) {
View Full Code Here

Examples of net.rim.device.api.system.PersistentObject

                        SHORTCUT_ID, APP_DESCRIPTOR_INDEX);
        HomeScreen.addShortcut(newShortcut, _homeScreenLocationPicker
                .getLocation());

        // Store the directory URL in the persistent store for this sample
        final PersistentObject store =
                PersistentStore
                        .getPersistentObject(HomeScreenDemo.HOMESCREEN_DEMO_ID);
        synchronized (store) {
            store.setContents(_pictureDirectoryURL);
            PersistentObject.commit(store);
        }

        Dialog.inform("Shortcut added successfully.");
    }
View Full Code Here

Examples of net.rim.device.api.system.PersistentObject

        // content state changes.
        PersistentContent.addListener(new PersistentStoreListener());

        // Persist an object protected by a code signing key. Please see
        // instructions above.
        final PersistentObject controlledStore =
                PersistentStore
                        .getPersistentObject(PERSISTENT_STORE_DEMO_CONTROLLED_ID);
        synchronized (controlledStore) {
            final CodeSigningKey codeSigningKey =
                    CodeSigningKey.get(CodeModuleManager
                            .getModuleHandle("PersistentStoreDemo"), "ACME");
            controlledStore.setContents(new ControlledAccess(new Vector(),
                    codeSigningKey));
            PersistentObject.commit(controlledStore);
        }

        // Retrieve the persistent object for this application
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.