I had the same problem and it was driving me nuts. I think it's a bug.
Below is how i worked-around it.

Do what you do now by calling insertImage(...).
This will insert the image into the data-base; however, thumbnails are
not correctly generated and the SIZE attribute is 0 (your problem that
you see).

Execute a query, and use the cursor to get the physical file-path (use
the ImageColumns.DATA).
Using the physical file-path, use the MediaScanner
(MediaScannerConnection) to scan your newly inserted image.
After the MediaScanner has finished, querying your image on
ImageColumns.SIZE (and other attributes) should work correctly.

I suggest to do this in a seperate worker-thread... it is kinda-slow.

On Mar 26, 9:47 am, Matthias <m.kaepp...@googlemail.com> wrote:
> Hi,
>
> I am uploading images to our webservice from the phone, and thus I
> need to know the exact size of an image. I noticed that with some
> photos from the G1, the webservice always failed, and found out that
> it's due to the file size always being 0 for the latest image in the
> database.
>
> Is this a known bug? What else can I do to find out the size of an
> image on the phone without going through the DB? I want to avoid
> writing the whole image to a byte buffer just to find out its size...
>
> here is some code to play with:
>
>                 ContentResolver contentResolver = getContentResolver
> ();
>                 Cursor c = contentResolver.query(
>                         Uri.parse("content://media/external/images/
> media"),
>                         new String[] { Images.ImageColumns._ID,
>                                 Images.ImageColumns.DISPLAY_NAME,
>                                 Images.ImageColumns.SIZE }, null,
> null, null);
>                 while (c.moveToNext()) {
>                     Log.d("PHOTO", c.getLong(0) + " " + c.getString(1)
> + " "
>                             + c.getLong(2));
>                 }
>                 c.close();
>
> This gives me 0 in the third column for the last entry (that's the
> newest photo).
--~--~---------~--~----~------------~-------~--~----~
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
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to