Hi Mark,
thanks for your response.
Indeed that line was wrong. Here is what the method looks like now. I
don't get the exception from within my code. Log shows the same as I
posted above and picture is not shown. The picture positively exists
and is on sdcard. Could it be that it has to be in Camera directory?
Thanks.
public ParcelFileDescriptor openFile(Uri uri, String mode)
throws FileNotFoundException {
Context ctx = this.getContext();
File FILE_NAME = new File(DataAdapter.DATABASE_FILE_PATH,
"test.jpg");
try {
// now open the file descriptor
ParcelFileDescriptor result =
ParcelFileDescriptor.open(FILE_NAME,
ParcelFileDescriptor.MODE_READ_ONLY);
return result;
} catch (Exception ex) {
int a = 9;
a = a+1;
throw new RuntimeException(ex);
}
}
On Apr 12, 11:07 am, Mark Murphy <[email protected]> wrote:
> gnugu wrote:
> > It fails in DatabaseUtils method:
>
> > public static void readExceptionWithFileNotFoundExceptionFromParcel(
> > Parcel reply) throws FileNotFoundException {
> > int code = reply.readInt();
> > if (code == 0) return;
> > String msg = reply.readString();
> > if (code == 1) {
> > *** this is where the exception is thrown *****
> > throw new FileNotFoundException(msg);
> > } else {
> > DatabaseUtils.readExceptionFromParcel(reply, msg, code);
> > }
> > }
>
> > Does anybody know what int code = reply.readInt(); is for? Why is
> > it returning 1?
>
> That code is meaningless to you. It would appear that you are having an
> exception inside your ContentProvider, probably a FileNotFoundException.
> Add yourself an exception handler in the ContentProvider to catch the
> exception there, then work to fix it.
>
> >>> ParcelFileDescriptor result =
> >>> ParcelFileDescriptor.open(ctx.getFileStreamPath(FILE_NAME.toString()),
> >>> ParcelFileDescriptor.MODE_WORLD_READABLE);
>
> Your use of getFileStreamPath() would appear to be invalid.
> getFileStreamPath() "returns the absolute path on the filesystem where a
> file created with openFileOutput(String, int) is stored". You are not
> using openFileOutput(), and FILE_NAME is probably not valid for use with
> getFileStreamPath().
>
> --
> Mark Murphy (a Commons
> Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> Android Development Wiki:http://wiki.andmob.org
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
To unsubscribe, reply using "remove me" as the subject.