Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 69
Registered: ‎07-30-2009
My Device: Not Specified
Accepted Solution

Store Bitmap in persistent

Hi all,

 

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

Developer
Posts: 1,041
Registered: ‎07-16-2008
My Device: ಠ_ಠ

Re: Store Bitmap in persistent

Objects that go in the persistence store must implement the Persistable interface. Bitmap does not. You can however use the Runtime store if you don't need it to survive a reboot. Otherwise you'll have to save to the file system or persist the byte array.

Developer
Posts: 587
Registered: ‎01-19-2010
My Device: BOLD 9700 OS5.0.0.x on Rogers Canada
My Carrier: Rogers

Re: Store Bitmap in persistent

Try this:

 

 

public myClass implements Persistable
{
  Vector v;
  
  public myClass () 
  {
    v = new Vector (1, 1);
  }
  
  public void addPic (Bitmap pic)
  {
    v.addElement (pic);
  }
  
  public void insertPic (Bitmap pic, int index)
  {
    v.insertElementAt (pic, index);
  }
  
  public void removePic (int index)
  {
    v.removeElementAt (index);
  }
}

 

 

Hope that helps,

~Dom

----------------------------------------------------------------------------
chown -R us ./base
~J!NX
Developer
Posts: 69
Registered: ‎07-30-2009
My Device: Not Specified

Re: Store Bitmap in persistent

Hi DAquilina..

 

 

                     Thanks for your post ... I used that but no use ... I got the same error again is there any other way to do this .....

 

 

 

 

Developer
Posts: 16,997
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Store Bitmap in persistent

you can persist a byte array, use bitmap getARGB or encoded image getData() to get a picture into serializable format.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Highlighted
Developer
Posts: 69
Registered: ‎07-30-2009
My Device: Not Specified

Re: Store Bitmap in persistent

Hi simon_hain,

 

                           I will try this ... thanks for your idea ...Smiley Happy