1

I am working on a camera app, I take my picture and the data is gathered as a byte[]...I don't want to store the images on the phones memory, what I want to be able to do is store the byte array for each capture up to a max of 5. So I'm wondering is it possible to create an array of byte arrays? Then I can add, remove arrays at the specified index location. Perhaps an array list? or do I have to use a db?

I've researched but came up with nothing, any thoughts would be appreciated.

*EDIT*

So just to ensure what I'm doing is correct here is my code..

public void addImage(byte[] IMdata) {
        // TODO Auto-generated method stub

        //Traverses Through ImageByteArray
        for (int i = 0; i < ImageByteArray.length; i++) {
            //Checks index position is empty
            if (ImageByteArray[i] == null) {
                //If so store IMdata in the Array
                ImageByteArray[i] = IMdata;
            }
        }
    }
DJ-DOO
  • 4,545
  • 15
  • 58
  • 98

1 Answers1

3

So I'm wondering is it possible to create an array of byte arrays?

Yes , its called two-dimentaional arrays(scroll down to Accessing Elements of a Multidimensional Array.

byte[][] twoDByteArray=new byte[5][1024];

Related post.

Community
  • 1
  • 1
wtsang02
  • 18,603
  • 10
  • 49
  • 67
  • You never know how big that array is going to be when the user captures an image. So allocating 5 x 1024 seems useless. Maybe allocating 5 x unset is more better. Something like: `byte[][] twoDByteArray = new byte[5][];` – gunar Jul 18 '13 at 14:30
  • @gunar its a sample code. I assume that op understand 1d byte arrays. and how he will use it depends on him. – wtsang02 Jul 18 '13 at 14:32