-1

I am storing a string[][]-array into a database as a "blob". Loading the data, I initially get a byte[]-array, which I then need to decode to string[][] again.

So: Can anywone tell me if there is a way to convert a byte[]-array to a string[][]-array (on Android)? Or if there is a way to convert a byte[]-array to an ArrayList ?

I asked a similar question once, but the question was referring to blobs.

5
  • Can you explain why you would need something like this? Commented Jul 24, 2011 at 16:49
  • What does it mean to convert a 1D array to a 2D array, let alone 2D array of String? What's the conversion rule? It normally makes sense to talk about decoding a byte[] to a String. This seems off by two whole dimensions! Commented Jul 24, 2011 at 18:11
  • Well, I am storing a string[][]-array to a database as a "blob". Loading the data, I initially get a byte-array, which I then need to decode to a string[][]-array. Commented Jul 24, 2011 at 18:14
  • 1
    "I am storing". Can you clearify? What magic is applied to make your string[][] a blob (byte[]) in DB? Commented Jul 24, 2011 at 18:24
  • I simply stored the string[][]-array "as is" with "INSERT INTO..." into a column with "blob" as datatype. Commented Jul 24, 2011 at 18:35

1 Answer 1

3

You would normally convert a byte array to a single blob - why would you want an array of blobs? Would you want a single blob per byte? That sounds unlikely.

Creating a single blob for an array of bytes is easy though... for example, with a PreparedStatement:

statement.setBlob(parameterIndex, bytes);
Sign up to request clarification or add additional context in comments.

15 Comments

Thank you for your answer, please see my edited initial post which now specifies what I want to achieve by this conversion.
@deimos: Now your title talks about converting byte arrays to blobs, while your question talks about converting blobs to strings. Which is it?
Eventually I need to convert a byte[]-array to a string[][]-array. To do this the way presented in my initial post, I would need a blob-array, not a byte-array. So if either one of the questions is answered, it would help me a lot.
@deimos1988: It's not clear why you need to get a blob involved at all. Do you just need to convert byte arrays into strings? If so, please edit your question to reflect that.
I changed the title to what I eventually need. If you know how to accomplish that, I would be very grateful.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.