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: 745
Registered: ‎01-04-2009
My Device: 8300, 8800, 8700f, 9000
Accepted Solution

adding data to DataBuffer

hi, how can i add more data to the buffer that already has some values? example:

 

byte[] _byte = new byte[3]; _byte[0] = 'A'; _byte[1] = 'B'; _byte[2] = 'C'; DataBuffer_buffer = new DataBuffer(_byte, 0, 3, false);

 

ok, here i've got values 'A','B', 'C' in my dataBuffer. but later i wanna put some more bytes in it:

byte[] _secondByte = new byte[3]; _secondByte[0] = 'D'; _secondByte[1] = 'E'; _secondByte[2] = 'F';

 

and now i want to add _secondByte to the _buffer but without loosing A,B,C.. i want to have in my _dataBuffer A,B,C,D,E,F values..

 

i tried methods as setData but they overwrite the data that was put at the beginning (A,B,C).

 

 can anyone suggest me anything?

 

 kind regards

Developer
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: adding data to DataBuffer

DataBuffer_buffer.setPosition(DataBuffer_buffer.getLength()); DataBuffer_buffer.writeByteArray(_secondByte);

 




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Developer
Posts: 745
Registered: ‎01-04-2009
My Device: 8300, 8800, 8700f, 9000

Re: adding data to DataBuffer

thx!
Highlighted
Developer
Posts: 97
Registered: ‎07-17-2008
My Device: Not Specified

Re: adding data to DataBuffer

Hi,

 

Can we write data from databuffer into file on SDCard?

Can we read data from file on SDCard to databuffer?

 

I wanted to write the databuffer data to file and read the data from the file.

Please provide sample if anyone have.

 

Thanks in advance.

 

 

Warm regards,

Shubhangi