[android-developers] Re: Loading internal html content in android web view
I can get it to recognize the file's existence if I remove the file://
from the front of the path. But then the web view loads a blank white
page.
On Dec 6, 10:01 am, tatebn <brandonnt...@gmail.com> wrote:
> I'm trying to load internal content in an android web view. The
> content is in a content directory that's been unzipped into the app's
> files directory. I can verify that the files are there by using the
> adb shell. However I keep getting an error in the web view that the
> file doesn't exist. I'm using a content provider for to load this.
> It's registered correctly and being called. And the file path it
> prints out is the same as the file path in the adb shell.
>
> public class InternalContentProvider extends ContentProvider{
>
> private static final String TAG = "InternalContentProvider";
>
> @Override
> public ParcelFileDescriptor openFile(Uri uri, String mode) throws
> FileNotFoundException{
> String filePath = "file://" + this.getContext().getFilesDir()
> + "/content" + uri.getPath();
> File file = new File(filePath);
>
> Log.i(TAG, "File uri = " + filePath);
> Log.i(TAG, "File name = " + file.getName());
>
> ParcelFileDescriptor parcel = ParcelFileDescriptor.open(file,
> ParcelFileDescriptor.MODE_READ_ONLY);
> return parcel;
> }
>
> @Override
> public boolean onCreate() {
> System.out.println("Created ContentProvider");
> return true;
> }
>
> @Override
> public int delete(Uri uri, String s, String[] as) {
> throw new UnsupportedOperationException("Not supported by this
> provider");
> }
>
> @Override
> public String getType(Uri uri) {
> return "text/html";
> }
>
> @Override
> public Uri insert(Uri uri, ContentValues contentvalues) {
> throw new UnsupportedOperationException("Not supported by this
> provider");
> }
>
> @Override
> public Cursor query(Uri uri, String[] as, String s, String[] as1,
> String s1) {
> throw new UnsupportedOperationException("Not supported by this
> provider");
> }
>
> @Override
> public int update(Uri uri, ContentValues contentvalues, String s,
> String[] as) {
> throw new UnsupportedOperationException("Not supported by this
> provider");
> }
>
> }
>
> I'm doing this in the android emulator. API level is 8.
--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home