Hi,
i am trying to load an html file which refers an image stored in the
sdcard. Actualy the html is provided by a local servlet. in the html,
i have this line "<img id="toto" src="file:///sdcard/path/path/
toto.png"/><br>".
When i used that,  i had this error : " Not allowed to load local
resource: file://".

I find out that android does not allow this kind of things for
security reasons . So i searched  on Internet(see links at the ends)
and i saw that i need to create my own ContentProvider to handle the
way to access the local files. I did it by creating a
LocalContentProvider that extends ContentProvider and i overwrited the
method openFile(android.net.Uri uri, java.lang.String mode). Then i
modified the androidManifest to add the provider.

androidManifest:
<provider android:name="LocalContentProvider"
android:authorities="com.myCompany.myPackageName" />

LocalContentProvider (stored in com.myCompany.myPackageName):

public ParcelFileDescriptor openFile(Uri uri, String mode) throws
FileNotFoundException {
                URI fileURI = URI.create( "file://" + uri.getPath() );
                File file = new File( fileURI );
                ParcelFileDescriptor parcel=null;
                try {
                        parcel = ParcelFileDescriptor.open(file,
ParcelFileDescriptor.MODE_READ_ONLY);
                } catch (FileNotFoundException e) {
                        Log.d(LOG_TAG,"Error finding: " + fileURI + "\n" + 
e.toString());
                }
                return parcel;
        }


After theses modifications i tryed with <img id="toto" src="content://
com.myCompany.myPackageName/sdcard/path/path/toto.png"/><br> and i
had
"Failed to find provider info for com.myCompany.myPackageName"




here is my question:

How can i change the html to make it access the local files via the
contentProvider ?
What am i doing wrong ?


i' based on theses exemples:

http://blog.tourizo.com/2009/02/how-to-display-local-file-in-android.html
http://www.techjini.com/blog/2009/01/10/android-tip-1-contentprovider-accessing-local-file-system-from-webview-showing-image-in-webview-using-content/



i' am using Android 1.6 SDK, Release 1 on windows XP.

Thank you for your help and i am sorry for my very bad english.

Yaya.






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