Hello Venkat,
 Thanks for responding.

What is the difference between /data/data(app.memory) and own package
application memory? I thought they both are same.

 Thanks for the code, I am already able to write directly but I don't
want to do that because I want my image to be listed in Gallery on
save.

On Feb 23, 11:43 am, venkat ranjit <ranjit0...@gmail.com> wrote:
> hi amit ,
>
>          in android we have no priviliges to write /data/data(app.memory)
> but we have premissions to write files in our own package application
> memory.i am sending a files that read and write data in application memory
> and sdcard both , i think this will helps u .
>
> Regards,
> Ranjit....
>
> On Tue, Feb 23, 2010 at 11:51 AM, A R <amit.r...@gmail.com> wrote:
> > Hi,
>
> >  I am trying to store an image in phone memory /data/data/com.myapp/
> > files/here.jpeg but I keep getting an exception. If I try to store the
> > image using the normal 'FileOutputStream' it works fine. Can anyone
> > point out what am I doing wrong? I want to store an image in my phone
> > memory app folder so that when user is setting wallpaper the image can
> > be listed in 'gallery'. I do not want to store the image on sdcard.
>
> >  The same code works fine if I store the image in sdcard, only thing I
> > change is EXTERNAL_CONTENT_URI
>
> > ContentValues values = new ContentValues();
> >                values.put(MediaStore.MediaColumns.DATA, outPath);
> >                values.put(MediaStore.MediaColumns.TITLE, "testing1");
> >                values.put(MediaStore.MediaColumns.SIZE, file.length());
> >                values.put(MediaStore.MediaColumns.MIME_TYPE, "image/jpeg");
>
> >                Uri uri =
>
> > context.getContentResolver().insert(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI,
> > values);
>
> >                Bitmap sourceBitmap = BitmapFactory.decodeByteArray(data, 0,
> > data.length);
>
> >                try {
> >                    OutputStream outStream =
> > context.getContentResolver().openOutputStream(uri);
> >                    sourceBitmap.compress(Bitmap.CompressFormat.JPEG, 50,
> > outStream);
> >                    outStream.close();
> >                } catch (Exception e) {
> >                    Logger.d("exception while writing image: ");
> >                }
>
> > The exception I am getting is:
>
> > 02-23 05:56:30.036: ERROR/MediaProvider(188): File creation failed
> > 02-23 05:56:30.036: ERROR/MediaProvider(188): java.io.IOException:
> > Parent directory of file is not writable: /data/data/com.myapp/files/
> > somefile.jpeg
> > 02-23 05:56:30.036: ERROR/MediaProvider(188):     at
> > java.io.File.createNewFile(File.java:1263)
> > 02-23 05:56:30.036: ERROR/MediaProvider(188):     at
>
> > com.android.providers.media.MediaProvider.ensureFileExists(MediaProvider.java:
> > 1670)
> > 02-23 05:56:30.036: ERROR/MediaProvider(188):     at
> > com.android.providers.media.MediaProvider.ensureFile(MediaProvider.java:
> > 1344)
> > 02-23 05:56:30.036: ERROR/MediaProvider(188):     at
>
> > com.android.providers.media.MediaProvider.insertInternal(MediaProvider.java:
> > 1413)
> > 02-23 05:56:30.036: ERROR/MediaProvider(188):     at
> > com.android.providers.media.MediaProvider.insert(MediaProvider.java:
> > 1381)
> > 02-23 05:56:30.036: ERROR/MediaProvider(188):     at
> > android.content.ContentProvider$Transport.insert(ContentProvider.java:
> > 150)
> > 02-23 05:56:30.036: ERROR/MediaProvider(188):     at
>
> > android.content.ContentProviderNative.onTransact(ContentProviderNative.java:
> > 140)
> > 02-23 05:56:30.036: ERROR/MediaProvider(188):     at
> > android.os.Binder.execTransact(Binder.java:287)
> > 02-23 05:56:30.036: ERROR/MediaProvider(188):     at
> > dalvik.system.NativeStart.run(Native Method)
> > 02-23 05:56:30.066: ERROR/DatabaseUtils(188): Writing exception to
> > parcel
> > 02-23 05:56:30.066: ERROR/DatabaseUtils(188):
> > java.lang.IllegalStateException: Unable to create new file: /data/data/
> > com.myapp/files/somefile.jpeg
> > 02-23 05:56:30.066: ERROR/DatabaseUtils(188):     at
> > com.android.providers.media.MediaProvider.ensureFile(MediaProvider.java:
> > 1345)
> > 02-23 05:56:30.066: ERROR/DatabaseUtils(188):     at
>
> > com.android.providers.media.MediaProvider.insertInternal(MediaProvider.java:
> > 1413)
> > 02-23 05:56:30.066: ERROR/DatabaseUtils(188):     at
> > com.android.providers.media.MediaProvider.insert(MediaProvider.java:
> > 1381)
> > 02-23 05:56:30.066: ERROR/DatabaseUtils(188):     at
> > android.content.ContentProvider$Transport.insert(ContentProvider.java:
> > 150)
> > 02-23 05:56:30.066: ERROR/DatabaseUtils(188):     at
>
> > android.content.ContentProviderNative.onTransact(ContentProviderNative.java:
> > 140)
> > 02-23 05:56:30.066: ERROR/DatabaseUtils(188):     at
> > android.os.Binder.execTransact(Binder.java:287)
> > 02-23 05:56:30.066: ERROR/DatabaseUtils(188):     at
> > dalvik.system.NativeStart.run(Native Method)
>
> > --
> > 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<android-developers%2bunsubscr...@googlegroups.com>
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en
>
>
>
>  Helper.java
> 8KViewDownload
>
>  AndroidHelper.java
> 47KViewDownload

-- 
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