Hi

I am puzzled how best to copy a JPEG image data bytes held by the
MediaStore.Images ContentProvider to a byte []  within an Activity. I
am not certain about how the java.io
Classses fit into my scenario...

So a sketch of the code might look something like ...

import android.provider.MediaStore.Images;
import android.net.Uri;
import android.database.Cursor;

<SNIP...>

</SNIP>
Uri extImagesUri = Images.Media.EXTERNAL_CONTENT_URI; // Images on SD
Card
// Obtain a  Cursor
Cursor cur = managedQuery(extImagesUri, null, null, null, null);
int rowIndex = cur.getColumnIndexOrThrow(Images.ImageColumns._ID);
Uri imageUri = null;
byte [] imageBytes = null;
String rowStr = null;
InputStream inStream=null;
OutputStream outStream = null;


// Iterate through cursor rows
cur.moveToFirst();
while ( cur.moveToNext()  )  {

    // Get RowID
    long rowID = cur.getLong( rowIndex );

    // Image URI
    rowStr = (new Long(rowID)).toString();
    imageUri = Uri.withAppendedPath(extImagesUri, rowStr) ;

   // Now open an InputStream or OutputStream or a File ??
   <Please Help Here !!>
   inStream = getContentResolver().openInputStream( imageUri );
      // OR ??
   outStream = getContentResolver().openOutputStream( imageUri );
      // OR ??
    ParcelFiledescriptor pFD = getContentResolver().
openFileDescriptor(imageUri, "r");
    // then open a FileInputStream ??



   // transfer (copy) image content bytes  to imageBytes array
   < Please help here !!>

   // do something with imageBytes ...

}

Can someone please give me some pointers. I am rather a Java newbie
so
am notclear about which of the java.io classes to leverage.

Thanks
Graeme
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new Android 0.9 SDK beta!
http://android-developers.blogspot.com/2008/08/announcing-beta-release-of-android-sdk.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to