Android - getting from a Uri to an InputStream to a byte array?

Posted by AP257 on Stack Overflow See other posts from Stack Overflow or by AP257
Published on 2010-03-12T22:46:05Z Indexed on 2010/03/12 22:47 UTC
Read the original article Hit count: 893

Filed under:

Hi there

I'm trying to get from an Android Uri to a byte array.

I have the following code, but it keeps telling me that the byte array is 61 bytes long, even though the file is quite large - so I think it may be turning the Uri string into a byte array, rather than the file :(

  Log.d(LOG_TAG, "fileUriString = " + fileUriString);
  Uri tempuri = Uri.parse(fileUriString);
  InputStream is = cR.openInputStream(tempuri);
  String str=is.toString();
  byte[] b3=str.getBytes();
  Log.d(LOG_TAG, "len of data is " + imageByteArray.length
     + " bytes");

Please can someone help me work out what to do?

The output is "fileUriString = content://media/external/video/media/53" and "len of data is 61 bytes".

Thanks!

© Stack Overflow or respective owner

Related posts about android