Store Bitmap in persistent

Hi all

I need to store a vector to bitmap image in persistent... But I got an exception (NonPersist ableObject Exception)... How to do this

You can make persistent byte array, use getARGB bitmap or image in GetData to get a picture in a serializable format.

Tags: BlackBerry Developers

Similar Questions

  • can we save the bitmap to persistent store?

    City previous forums:

    Smiley

    Messages: 29
    From: Canada
    Join date: May 2008

    can we save the bitmap to persistent store?
    Posted the: July 14, 2008 12:41
    Response
    I am trying to save a bitmap in Bank persistence and get an error msg saying Bitmap is not persistent.

    is it possible to save a bitmap?

    Thank you

    Yes it is possible.  You can use the Bitmap.getARGB method to get an array of bytes of the Bitmap image.  Then store its contents in a ByteVector.

    I am aware of the problem and would use a solution like that set up by MiuTunes.  Basically, generating thumbnails on the front and store them on the SD card.

    As neil says, there is a small performance lag, compared, but I find personally unacceptable in this application.  Don't know what you develop, and perhaps there are moments where in memory is better.  I'm also assuming (wrongly?) that you were going to leave them in the persistent store after your application ends.  Anyway, Neil knows more about what I do.

  • How can I store bitmap data in the SharedObject class?

    Any ideas?

    What I tried to do. First run the "code" then the "Second code '.

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    <mx:Script>
         <![CDATA[
              import mx.controls.Image;
              private function init():void
              {
                   var o:SharedObject = SharedObject.getLocal("t1","/");
                   
                   //First code
                   o.clear();
                   var bit:Bitmap= new Bitmap(new BitmapData(100,100,false,0));
                   o.data.bit=bit;
                   o.flush();
                   
                   //Second code               
                   var bit:Bitmap = o.data.bit;
                   var pic:Image = new Image();
                   pic.source=bit;
                   Application.application.addChild(pic);
                   
                   
              }
         ]]>
    </mx:Script>     
    </mx:Application>
    

    godilya,

    Sorry about that. Since there were a lot of mistakes in your code I just fixed all. But you are right that even after he still not actually saved it to the SO.

    I would recommend saving them as a ByteArray, that appears in literature as one of the supported by the SharedObject object classes.

    First code

    var bitmap: Bitmap = new Bitmap (BitmapData (100,100,false,0xFF0000) new);

    var bitmapData:BitmapData = bitmap.bitmapData;

    var byteArray:ByteArray = bitmapData.getPixels (bitmapData.rect);

    so. Clear();

    so.data.byteArray = byteArray;

    so. Data.Width = bitmapData.rect.width;

    so. Data.Height = bitmapData.rect.height;

    so. Flush();

    Second code

    var byteArray:ByteArray = ByteArray (so.data.byteArray);

    var bitmapData:BitmapData = new BitmapData (so.data.width, so.data.height);

    bitmapData.setPixels (bitmapData.rect, byteArray);

    var bitmap: Bitmap = new Bitmap (bitmapData);

    Photo: Image of var = new Image();

    PIC.source = bitmap;

    Application.application.addChild (pic);

    I have tested it properly, with a comment, then the other.

    Thank you

    Philippe

    Post edited by: Philip Keiter

  • Store the object in a persistent storage

    Hello

    I want to store the cusom object in the persistent store.here is my custom class:

    public class {UserData

    OrgName string;
    Time to string;
    String authTocken;
    Public UserData (orgName, String authTocken, String time, String)
    {
    this.orgName = orgName;
    This.Time = time;
    this.authTocken = authTocken;

    }
    public String getOrgName() {}
    return orgName;
    }
    {} public void setOrgName (String orgName)
    this.orgName = orgName;
    }
    public String getTime() {}
    back in time;
    }
    {} public void setTime (string time)
    This.Time = time;
    }
    public String getAuthTocken() {}
    Return authTocken;
    }
    {} public void setAuthTocken (String authTocken)
    this.authTocken = authTocken;
    }

    }

    and I use the following class of persistent storage to store the data.

    / public final class PersistentStoreContents implements {Persistable
    private CAMailMinderHashTable mElements = null;
    static private instance of PersistentStoreContents = null;
    Private static final long KEY = 0x67c5b66a2bcd1dfcL;
    private PersistentObject persistentObject = null;

    /**
    * Gets the single instance of the database.
    *
    * only @return of the database instance
    */
    public static getInstance() {} PersistentStoreContents
    try {}
    If (instance == null) {}
    Logger.out ("PersistentStoreInfo", "creation of the storage object");
    instance = new PersistentStoreContents();
    }
    } catch (Exception e) {}
    instance = null;
    }
    return instance;
    }

    private PersistentStoreContents() {}
    persistentObject = PersistentStore.getPersistentObject (KEY);
    synchronized (persistentObject) {}
    If (persistentObject.getContents () == null) {}
    persistentObject.setContents (new CAMailMinderHashTable());
    persistentObject.commit ();
    }
    }

    mElements = persistentObject.getContents ((CAMailMinderHashTable));
    If (mElements == null) {}
    Logger.out ("PersistentStoreInfo", "*" + (mElements is nothing));
    mElements = new CAMailMinderHashTable();
    }

    }

    public String getElement (String key) {}
    Logger.out ("PersistentStoreInfo", "getElement:" + key);
    Return (String) mElements.get (key);
    }

    ' Public Sub setElement (String key, String value) {}
    Logger.out ("PersistentStoreInfo", "setElement:" + key + value);
    mElements.put (key, value);
    persistentObject.setContents (mElements);
    persistentObject.commit ();
    }

    UserData public getElement2 (String key) {}
    Logger.out ("PersistentStoreInfo", "getElement:" + key);
    Return mElements.get (key) (UserData);
    }

    public void setElement2 (String key, UserData userData) {}
    Logger.out ("PersistentStoreInfo", "setElement:" + key);
    mElements.put (key, userData);
    Logger.out ("PersistentStoreInfo", "added");
    persistentObject.setContents (mElements);
    Logger.out ("PersistentStoreInfo", "game content");
    persistentObject.commit ();
    Logger.out ("PersistentStoreInfo", "Validate");
    }

    Public list getAllKeys() {}
    Logger.out ("PersistentStoreInfo", "getElement:" + key);
    Return mElements.keys ();
    }
    }

    I use the follwinng code to insert data :

    PersistentStoreContents ch = PersistentStoreContents.getInstance ();
    UserData = us new UserData("gmail.com","1111","aaaa");
    ps.setElement2 ("[email protected]", US);

    But it is not inserting data in the persistent store. App is struck to the persistent store setContent method... any idea on this?

    the object you put in the store has implemented persistable, not your utility class.

  • The BlackBerry object Handles and the persistent object Handles?

    Can someone please what are the object Handles and handles of object persistent in Blackberry? and how are they different?

    Object handles are pointers to a Java object.  Each object that you create in your application using one of them.  Similarly, each object stored in the persistent store contains a handful.

    If you have a complex object you want to store in the persistent store, as a vector that contains a number of complex classes, you can store the vector in a group of objects that you want to save the object handles.  Grouped objects use a single Treaty when it is stored in the persistent store.  The disadvantage is to ungroup the object for editing.

    You will need to balance saving handles object against the drop in performance of separate objects.  Object groups are ideal for the complex elements that are frequently changed.

  • Question about the persistent object

    Hello

    When I used to store data using persistent object, data also will be deleted after uninstalling the app.

    Is there any data keep possibility even if the app is uninstalled?

    Can anyone give me a suggestion on this?

    Thank you.

    Objects are deleted when no request refers to them.

    So, if you have implemented a custom persistable object, whis would explain the removal.

    Use "Vanilla" persistable objects in the store, such as Hashtable.

  • Delete PersistentObject of the store when the application is uninstalled

    Hello

    I expect that on request, uninstall the PersistentObjects used by the application would be removed, but this does not happen.

    How can I achieve it

    Thanks yo

    If you create a custom class that is persistable your persistent data will be deleted when the application is uninstalled.  If you use a class set of BlackBerry APIs, such as String and store in the persistent store, it is not deleted when the application is uninstalled.  This is explained here:

    Manage the data recorded during the withdrawal of an application

    http://supportforums.BlackBerry.com/T5/testing-and-deployment/handle-stored-data-when-removing-an-AP...

  • Question about persistent storage

    By reading the developer's guide, I read this

    The following native data types can also be stored persistently:

    • java.lang.Boolean
    • java.lang.Byte
    • java.lang.Character
    • java.lang.Integer
    • java.lang.Long
    • java.lang.Object

    ...

    Previously, I was looking for a way to store a BlackBerryContact object with persistence.  The answer was that basically it is possible to reimplmenting the class myself.  However, if objects can be stored, would it be possible to mount the BlackBerryContact as an object, store it and cast then back after recovery?  It seems a bit simple to work actually, but I thought I could ask for more.  Happy Obama day!

    It is not advisable to directly store instances of outer class.

    External means that these classes are not yours.

    For example - if you have created an instance of the com.mycompany.myapp.MyClass class and stored in the persistent store - then when you uninstall your application - these instances of class will be removed too the persistent store.

    But if you directly - save an instance of the class java.util.Vector, or BlackberryContact, they will remain in persistent memory, your application is uninstalled.

    It is not a good approach.

    Use Memento design pattern.

    Create a class which instance stores snapshot of information to start an instance of BlackberryContact and store it in persistent memory.

  • How to store the information safely register?

    Some require for my application:

    -When remove app, information register is always stay

    -What app, registry info update is intact

    I try with PersistentStore but I still want to see idea of expert for a better solution. Thank you very much!

    If the info should stay, you will need to use a preset to store your information, String, Boolean, Integer, or Vector, Hashtable etc.
    If you put a class of its own in the store that implements Persistable store is deleted if you remove the application.

  • How to load images with a delay?

    Let's say I have a JSON from an HTTP request. The JSON contains several JPG and text links.

    For each JPG link and text, I want that they be displayed in a field like that.

    And here is the code in the field:

    public ProductField extends Field {
    
        String text;
        Bitmap bmp
    
        public CustomField(String text, String imageURL){
            bmp = Bitmap.getBitmapResource("blank.png");
        }
    
        public void paint(Graphics g){
            //....
        }
    
        public void updateBitmap(String url){
            bitmap = BitmapUtil.loadBitmapFromURL(url);
    
            // draw the bitmap on XYRect
            dest = new XYRect(0, 0, bitmap.getWidth(), bitmap.getHeight());
            invalidate();
        }
    }
    

    I realize that load images takes time, so I don't load them immediately. I have only to load the text and display an empty bitmap in the bitmap field. The actual bitmap will be charged when the updateBitmap() method is called.

    And here's how to add these field on the screen (not a 100% valid code, but I hope you will illustrate the idea)

    VerticalFieldManager vfm = new VerticalFieldManager
    
    // an array of bitmap URLS, which will be loaded later
    final String[] urls = new String[json_array_size];
    
    for (int x = 0; x < json_array.size; x++){
        CustomField field = new CustomField(..);
    
        // store bitmap URLs in array
        urls[x] = json_array.getJSONObject(x).getString("url");
        vfm.add(field);
        vfm.add(new SeparatorField());
    }
    
    Thread t = new Thread( new Runnable() {
        public void run() {
            for(int i = 0; i < len;i += 2) {
                synchronized(UiApplication.getEventLock()) {
                    CustomField cf = (CustomField) vfm.getField(i);
                    cf.updateBitmap(urls[i]);
               }
                try{
                    Thread.sleep(2000);
                }
                catch(Exception e){ }
                }
            }
    });
    

    Seems that all the images are loaded simultaneously. What I want is something like:

    display bitmap #1-2 seconds of delay - display bitmap #2 - delay 2 sec - display bitmap #3 - delay 2 sec etc..

    How to solve this problem?

    You can remove the block synchronized as you don't make any changes to the user interface, you read a value of a UI element.
    About your son, I can't get started, maybe a start() would help. do not race

  • My application is force to reboot my device

    Hi guys,.

    I developed an application that stores data in persistent (controlled access) store. The app has a few screens too, nothing major.

    Just today, I noticed a perculiar activity. It seems that my application deploys force phone restart. Even if I close the application, it still happens. It takes a few minutes but the phone restarts just on its own.

    Another strange thing is part of the object in the persistent store is missing. I have a class that stores a users details. One of the fields of this class is a vector that stores a collection of payment options.

    I searched here and found the logger.

    The last event in the log is:

    Name: System

    Severity: error
    GUID: 97c9f5f641d25e5f
    Time: March 10, 2012 17:59:03

    JVM:INFOp = 285d64e4, a = '7.0.0.585', o = '5.0.0.734', h = 7001204

    This probably doesn't mean much, but at least it's a start.

    I know I need my application with logger calls pepper to see exactly what is happening? Tutorials on this?

    The reason why I'm writing here is that I wonder if there are questions people have when storing persistent objects. Is there a limit on the size of the object, that you can store?

    Thank you.

    UPDATE:

    Just before I call store.commit () I put the property that contains the null vector.

    My phone has not restarted since that and test the application several times. Strange.

    I have a solution.

    Well, I was right back on the API interface Persistable and discovered my problem.

    Each class must implement explicitly Persistable. Void classes inherit any implementation of this interface.

    My parents PaymentOption Persistable implemented but the children do not have. Persistable implementation on children has fixed the problem.

    Hope this helps someone.

  • Deleting an application problem, please help.

    I have an application that persists data in flash. In the early stages of development, I used a ContentProtectedVector object for storage, but now I've changed in a class that extends ContentProtectedVector.

    My big problem is that now I installed the new version of the application and it did not work.

    When I try to erase your phone using javaLoader, I get an error saying port closed, and the device resets. Using BlackBerry Desktop Software, the unit resets immediately during the loading of applications on pc.

    For the moment, I can't delete this request by phone. Can someone help me?

    Is it possible to restore the default operating system? This will help me?

    He solved.  Removing the application one of the options-> advanced-> Applications Options does not work.

    I created another application that has erased the PersistentObject. After clearing the storage, I was able to delete the application with JavaLoader.

    I found a post very helpful on this forum, who helped me with this problem.

    http://supportforums.BlackBerry.com/T5/Java-development/remove-the-application-from-the-handheld/m-p...

    In the future I just store my own Persistable classes and extend the tables hash or vectors if necessary.

    Hope this might help other people.

  • Poblem to persistence storage

    Hi all

    In my application, I use the persistence store object to store the array of objects of the class defined by the user. But whenever I run my application it showed me the error 'Error JVM 104 NonPersistableObjectException' 7 stucks execution.

    In the integer part of the persistence object & all what I have try-catch instructions & I also tried with execution clean.bat hundreds of times. But I didn't come to any solution.

    Is there be no problem by storing the array of objects of class user-defined?... Please help me...

    Any help would be appreciated...

    Concerning

    Please note that all the objects that you want to store in the persistent store must be an instance of the class that implements the Persistable.

    In addition, all areas inside these objects must be an instance of the class that implements the Persistable.

    If the container object implements the Peristable interface, but there is a field that is not persistent, you get problems.

    Another point is that if you have an instance of Vector field, check this vector elements.

    All objects in this vector (or another container as an instance of the Hashtable object) must be an instance of the class that implements the Persistable.

  • CASE of clustering for FatWire 7.6P2

    Hello

    I managed to install FatWire 7.6P2 locally on Windows 7 with Weblogic Server 10.3.5 and Oracle 11gXE.

    I started with a single instance of CS and AC and added secondary members for CS and CASES. My setup is as follows - two managed servers each with their own CS and AC applications deployed. These two managed servers are part of the same cluster and machine slot the domain used.

    I followed all the steps mentioned in the guide of rollup under the section 'Deploy the Cluster CASE members' secondary.

    When I tried to enable replication of session for Weblogic server as described in the user guide

    < session descriptor - >

    replicated, persistent-store-type >

    < / persistent-store-type >

    true < url rewriting compatible >

    < / url-rewriting-enabled >

    < / session descriptor >

    I got the following error trying to start the servers managed for CS and CASE - applications [HTTP Session: 100083] the webapp: CS in application: CS has PersistenceStoreType value: replicated for http sessions, but the target list does contain not all members of the cluster: Cluster-0. Inhomogeneous deployment for replicated sessions is not allowed.


    I believe that this error is thrown because I have deployed my apps on managed servers one at a time and not to the cluster. So, I advanced and deleted the CS and CASE applications and deployed them again to the cluster by using one of the directories archives exploded for CS and the CASE.


    My question is: is it the right way to do grouping for the CS and CASES?


    I looked and didn't find any specific member property in the CS and CASE application directories, assuming all the ports and hostname are specific balancing load. The only specific property of members was on host.properties which is present in < cs_install_dir > / bin and I include it in the CLASSPATH and PRE-CLASSPATH entries in the setDomainEnv.cmd and startWeblogic.cmd files before you start managed servers.

    Kind regards

    Hari

    Hello Hari,

    Take a look at the deployment of Sites using WebLogic Server Clustering and replication of Session (Doc ID 1543509.1). It is intended for Sites WebCenter 11 g, but I think it will work for 7.6.2 Sites as well.

    Kind regards

    Stephan.

  • Recompose is the deletion of user data

    Hello

    I am currently to view assessment and I created a linked cloning dedicated with persistent discs separate and disposable Pool. I did some updates to the main image and tried to recompose. I tested my office by creating a folder on the desktop, and saving a few bookmarks in Chrome. After the restructuring was completed, I noticed that the folder I created on the desktop was gone and my favorites were also were lost. I thought I had another drive persistent was suppose to prevent this?  Thank you.

    It automatically adds the disk persistent except in cases where the profile already created on the gold statue.   Make sure that your user profile is not on the model and see if it will store everything on persistent disk.

Maybe you are looking for