I had a similar issue with storing temporary images (saving color-
corrected images).

It turned out that storing a temp image (just plain binary data; a
large array of int-s (ARGB)) on the SD-card was the fastest (still
slow, though).

Storing it on the phone, the cache (getCacheDir) or data
(getFilesDir), was way slower (about 2 times for writing) than storing
it on the SD-card. Note that i have a class-6 SD-card in my phone.

Another reason to use the SD-card instead of the cache is the limited
amount of phone-memory. Android will clear the cache when necessary,
but stil....

I call Bitmap.getPixels a number of times on a *large* bitmap, using a
temporary buffer, and write the contents of this buffer to a
FileOutputStream that points to a temp file on the SD-card. If you
have a *small* bitmap, just calling 'compres's using the PNG (no image-
quality loss) is sufficient.

Be sure to not assign an image extension (e.g ".jpg" or ".png") to the
name of this temporary file... it may show in the Gallery app :-)

On Oct 20, 9:02 am, Vitaly Polonetsky <topix...@gmail.com> wrote:
> Thanks for your reply, that's what I'm planing to do.My other question was
> where do I temporary store the image ?
> I can store it in EXTERNAL_CONTENT_URI, Context.getCacheDir() or
> Context.getFilesDir() ...
> But what's preferable and why ? (considering: deletion timing, permissions,
> locks, etc.)
> Personally, I would choose cache dir.
>
> On Tue, Oct 20, 2009 at 12:52 AM, Streets Of Boston <flyingdutc...@gmail.com
>
>
>
>
>
> > wrote:
>
> > You can delete it while handling the onActivityResult (this method is
> > called after your sub/child activity finishes).
>
> > On Oct 14, 10:02 am, m_vitaly <m_vit...@topixoft.com> wrote:
> > > Ok, but what if I want to delete if after issuing startActivity, can I
> > > do this ?
> > > And where should I store it then ?
>
> > > On Oct 14, 4:20 am, Streets Of Boston <flyingdutc...@gmail.com> wrote:
>
> > > > When you store it in the EXTERNAL_CONTENT_URI, your image can already
> > > > be shared with every other app on the phone.
>
> > > > When you added (inserted) the image, your result was a Uri. This Uri
> > > > can be used by any other app to obtain your image.
>
> > > > On Oct 13, 4:42 pm, m_vitaly <m_vit...@topixoft.com> wrote:
>
> > > > > My program creates a bitmap and successfully stores it on external
> > > > > storage (Images.Media.EXTERNAL_CONTENT_URI).
>
> > > > > The next option to implement is to share the image.
> > > > > I'm thinking about different way of doing it:
> > > > > 1. Save it as captured image (as before) and startActivity with
> > > > > Intent.ACTION_SEND intent with the saved image uri.
> > > > > 2. Save it in application's home directory (getFileStreamPath()),
> > > > > startActivityForResult as in 1. and I hope that I'll recieve a result
> > > > > when the message is sent.
> > > > > 3. Save it in some kind of temp/cache folder and don't bother about
> > > > > deleting it or delete it as in 2.
>
> > > > > Personally I prefer the second option.
>
> > > > > My questions are:
> > > > > Will it work with startActivityForResult() as in 2. ?
> > > > > Do I have access to temp/cache folder as in 3. ? If I do, Should I
> > > > > delete the file afterwards ?
> > > > > May be some flag for Intent.ACTION_SEND to delete the file
> > > > > afterwards ?
>
> > > > > Thanks.- Hide quoted text -
>
> > > - Show quoted text -
>
> --
> Best regards,
> Vitaly Polonetsky- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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