[android-developers] Re: WebView/Browser: How to browse files from the sdcard?

2009-01-12 Thread Asif k

Hi Mariano,

Can you please tell us what is the final result
and how u had implement those API to run your code

Thanks,
Asif

On Jan 12, 12:21 am, Mariano Kamp mariano.k...@gmail.com wrote:
 Once again, thanks.

 I found this 
 tutorial:http://www.anddev.org/tutproviding_data_in_a_contentprovider-t4073.html
 and will try that.

 I checked that the ContentProvider is called from the Browser... So the rest
 should work.

 On Sun, Jan 11, 2009 at 7:58 PM, Mark Murphy mmur...@commonsware.comwrote:





  Mariano Kamp wrote:
   I don't see how that should work?
   Wouldn't that be the same as the FileContentProvider?

  I cannot find a FileContentProvider class in the SDK or SDK samples. I
  see where there is one in the source code, and, yes, I think that's the
  basic idea.

   How would WebView learn about this provider.

  I believe you feed it a URL, like:

  content://your.provider.here/path/to/something.html

  But, again, I have not tried this myself, though I recall seeing some
  posts in this group, and maybe a blog post, covering this technique to
  some degree.

  --
  Mark Murphy (a Commons Guy)
 http://commonsware.com
  Android Training in Sweden --http://www.sotrium.com/training.php- 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
-~--~~~~--~~--~--~---



[android-developers] Re: WebView/Browser: How to browse files from the sdcard?

2009-01-12 Thread Mariano Kamp
As I said by private mail already. I am not there yet, but that doesn't
matter as I found this discussion:
http://groups.google.com/group/android-developers/browse_thread/thread/beae7de5e2500cb6/9891024d8ddfeefb
which talks exactly about using a homegrown content provider to serve files
directly.
Inside this article you'll find a link to this blogpost (
http://lucabelluccini.blogspot.com/2008/09/android-developers-google-group-focus.html)
which contains the working code.


On Mon, Jan 12, 2009 at 12:50 PM, Asif k asifk1...@gmail.com wrote:


 Hi Mariano,

 Can you please tell us what is the final result
 and how u had implement those API to run your code

 Thanks,
 Asif

 On Jan 12, 12:21 am, Mariano Kamp mariano.k...@gmail.com wrote:
  Once again, thanks.
 
  I found this tutorial:
 http://www.anddev.org/tutproviding_data_in_a_contentprovider-t4073.html
  and will try that.
 
  I checked that the ContentProvider is called from the Browser... So the
 rest
  should work.
 
  On Sun, Jan 11, 2009 at 7:58 PM, Mark Murphy mmur...@commonsware.com
 wrote:
 
 
 
 
 
   Mariano Kamp wrote:
I don't see how that should work?
Wouldn't that be the same as the FileContentProvider?
 
   I cannot find a FileContentProvider class in the SDK or SDK samples. I
   see where there is one in the source code, and, yes, I think that's the
   basic idea.
 
How would WebView learn about this provider.
 
   I believe you feed it a URL, like:
 
   content://your.provider.here/path/to/something.html
 
   But, again, I have not tried this myself, though I recall seeing some
   posts in this group, and maybe a blog post, covering this technique to
   some degree.
 
   --
   Mark Murphy (a Commons Guy)
  http://commonsware.com
   Android Training in Sweden --http://www.sotrium.com/training.php- 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
-~--~~~~--~~--~--~---



[android-developers] Re: WebView/Browser: How to browse files from the sdcard?

2009-01-12 Thread A R

I was recently able to solve this problem. I displayed an image saved
on the local file system in a WebView, the steps are same for html
file as well.

I wrote about it step by step here
http://www.techjini.com/blog/2009/01/10/android-tip-1-contentprovider-accessing-local-file-system-from-webview-showing-image-in-webview-using-content/

you dont need to implement the ContentProvider in so much details just
one method.

HTH

On Jan 12, 5:45 pm, Mariano Kamp mariano.k...@gmail.com wrote:
 As I said by private mail already. I am not there yet, but that doesn't
 matter as I found this 
 discussion:http://groups.google.com/group/android-developers/browse_thread/threa...
 which talks exactly about using a homegrown content provider to serve files
 directly.
 Inside this article you'll find a link to this blogpost 
 (http://lucabelluccini.blogspot.com/2008/09/android-developers-google-...)
 which contains the working code.

 On Mon, Jan 12, 2009 at 12:50 PM, Asif k asifk1...@gmail.com wrote:

  Hi Mariano,

  Can you please tell us what is the final result
  and how u had implement those API to run your code

  Thanks,
  Asif

  On Jan 12, 12:21 am, Mariano Kamp mariano.k...@gmail.com wrote:
   Once again, thanks.

   I found this tutorial:
 http://www.anddev.org/tutproviding_data_in_a_contentprovider-t4073.html
   and will try that.

   I checked that the ContentProvider is called from the Browser... So the
  rest
   should work.

   On Sun, Jan 11, 2009 at 7:58 PM, Mark Murphy mmur...@commonsware.com
  wrote:

Mariano Kamp wrote:
 I don't see how that should work?
 Wouldn't that be the same as the FileContentProvider?

I cannot find a FileContentProvider class in the SDK or SDK samples. I
see where there is one in the source code, and, yes, I think that's the
basic idea.

 How would WebView learn about this provider.

I believe you feed it a URL, like:

content://your.provider.here/path/to/something.html

But, again, I have not tried this myself, though I recall seeing some
posts in this group, and maybe a blog post, covering this technique to
some degree.

--
Mark Murphy (a Commons Guy)
   http://commonsware.com
Android Training in Sweden --http://www.sotrium.com/training.php-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
-~--~~~~--~~--~--~---



[android-developers] Re: WebView/Browser: How to browse files from the sdcard?

2009-01-12 Thread Mariano Kamp
Great, that looks good Amit.

You mentioned in your blog post the security circumvention. Do you have any
idea about what kind of security risk we are talking here?

On Mon, Jan 12, 2009 at 1:56 PM, A R amit.r...@gmail.com wrote:


 I was recently able to solve this problem. I displayed an image saved
 on the local file system in a WebView, the steps are same for html
 file as well.

 I wrote about it step by step here

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

 you dont need to implement the ContentProvider in so much details just
 one method.

 HTH

 On Jan 12, 5:45 pm, Mariano Kamp mariano.k...@gmail.com wrote:
  As I said by private mail already. I am not there yet, but that doesn't
  matter as I found this discussion:
 http://groups.google.com/group/android-developers/browse_thread/threa...
  which talks exactly about using a homegrown content provider to serve
 files
  directly.
  Inside this article you'll find a link to this blogpost (
 http://lucabelluccini.blogspot.com/2008/09/android-developers-google-...)
  which contains the working code.
 
  On Mon, Jan 12, 2009 at 12:50 PM, Asif k asifk1...@gmail.com wrote:
 
   Hi Mariano,
 
   Can you please tell us what is the final result
   and how u had implement those API to run your code
 
   Thanks,
   Asif
 
   On Jan 12, 12:21 am, Mariano Kamp mariano.k...@gmail.com wrote:
Once again, thanks.
 
I found this tutorial:
  http://www.anddev.org/tutproviding_data_in_a_contentprovider-t4073.html
and will try that.
 
I checked that the ContentProvider is called from the Browser... So
 the
   rest
should work.
 
On Sun, Jan 11, 2009 at 7:58 PM, Mark Murphy 
 mmur...@commonsware.com
   wrote:
 
 Mariano Kamp wrote:
  I don't see how that should work?
  Wouldn't that be the same as the FileContentProvider?
 
 I cannot find a FileContentProvider class in the SDK or SDK
 samples. I
 see where there is one in the source code, and, yes, I think that's
 the
 basic idea.
 
  How would WebView learn about this provider.
 
 I believe you feed it a URL, like:
 
 content://your.provider.here/path/to/something.html
 
 But, again, I have not tried this myself, though I recall seeing
 some
 posts in this group, and maybe a blog post, covering this technique
 to
 some degree.
 
 --
 Mark Murphy (a Commons Guy)
http://commonsware.com
 Android Training in Sweden --
 http://www.sotrium.com/training.php-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
-~--~~~~--~~--~--~---



[android-developers] Re: WebView/Browser: How to browse files from the sdcard?

2009-01-11 Thread Mark Murphy

Mariano Kamp wrote:
 Hi,
 
   I am trying to browse files from the sd card, but haven't had any
 success so far. Maybe I am doing something wrong, so I'd like to write
 down the steps for your feedback.
 
   The sample contains of an html file that references a png.
 
   (1)
 localhost:~ mkamp$ cat test.html
 html
   pHello World!img src=test.png/p
 /html
 
   (2) I transfer the two files to the sdcard like this:
 
 localhost:~ mkamp$ adb push test.html /sdcard/.
 10 KB/s (57 bytes in 0.005s)
 localhost:~ mkamp$ adb push test.png /sdcard/.
 709 KB/s (3180 bytes in 0.004s)
 
   (3) To check if they are there I get them back and compare the version
 I pulled back with the version I pushed doing the following:
 
 localhost:~ mkamp$ adb pull /sdcard/test.png test2.png
 829 KB/s (3180 bytes in 0.003s)
 localhost:~ mkamp$ adb pull /sdcard/test.html test2.html
 0 KB/s (57 bytes in 0.110s)
 localhost:~ mkamp$ diff test.html test2.html
 localhost:~ mkamp$ md5 test.png test2.png
 MD5 (test.png) =  49cde2f11086e4ebcb1aff45deaae750
 MD5 (test2.png) = 49cde2f11086e4ebcb1aff45deaae750
 
   So life should be good, right?
 
   (4) Well, when trying to browse those files in the Android browser
 with the url file:///sdcard/test.html I get Web page not available. The
 Web page at file:///scard/test.html could not be loaded as: The
 requested file was not found.
 
   (5) The system logs shows: 
 
 E/browser (  239): onReceivedError code:-13 The requested file was not
 found.
 D/browser (  239): updating cursor
 
 
   I feel really stupid failing at something so simple, but I just don't
 see what I am missing.

You cannot use the built-in Browser application to view local content,
apparently for security reasons.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
_The Busy Coder's Guide to Android Development_ Version 2.0 Available!

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



[android-developers] Re: WebView/Browser: How to browse files from the sdcard?

2009-01-11 Thread Mariano Kamp
OMG. That is such a blow. I didn't read anything like that in the WebView
documentation. I spent my vacation writing an offline client for Google
Reader. Puh. I already paid for a logo etc. Man that sucks ;-(

Any idea how to work around that?

I actually don't need it to work in the browser just in the WebView. Would
this help to work around the security issue? What kind of issue is that
anyway?

Mariano

On Sun, Jan 11, 2009 at 5:46 PM, Mark Murphy mmur...@commonsware.comwrote:


 Mariano Kamp wrote:
  Hi,
 
I am trying to browse files from the sd card, but haven't had any
  success so far. Maybe I am doing something wrong, so I'd like to write
  down the steps for your feedback.
 
The sample contains of an html file that references a png.
 
(1)
  localhost:~ mkamp$ cat test.html
  html
pHello World!img src=test.png/p
  /html
 
(2) I transfer the two files to the sdcard like this:
 
  localhost:~ mkamp$ adb push test.html /sdcard/.
  10 KB/s (57 bytes in 0.005s)
  localhost:~ mkamp$ adb push test.png /sdcard/.
  709 KB/s (3180 bytes in 0.004s)
 
(3) To check if they are there I get them back and compare the version
  I pulled back with the version I pushed doing the following:
 
  localhost:~ mkamp$ adb pull /sdcard/test.png test2.png
  829 KB/s (3180 bytes in 0.003s)
  localhost:~ mkamp$ adb pull /sdcard/test.html test2.html
  0 KB/s (57 bytes in 0.110s)
  localhost:~ mkamp$ diff test.html test2.html
  localhost:~ mkamp$ md5 test.png test2.png
  MD5 (test.png) =  49cde2f11086e4ebcb1aff45deaae750
  MD5 (test2.png) = 49cde2f11086e4ebcb1aff45deaae750
 
So life should be good, right?
 
(4) Well, when trying to browse those files in the Android browser
  with the url file:///sdcard/test.html I get Web page not available. The
  Web page at file:///scard/test.html could not be loaded as: The
  requested file was not found.
 
(5) The system logs shows:
 
  E/browser (  239): onReceivedError code:-13 The requested file was not
  found.
  D/browser (  239): updating cursor
 
 
I feel really stupid failing at something so simple, but I just don't
  see what I am missing.

 You cannot use the built-in Browser application to view local content,
 apparently for security reasons.

 --
 Mark Murphy (a Commons Guy)
 http://commonsware.com
 _The Busy Coder's Guide to Android Development_ Version 2.0 Available!

 


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



[android-developers] Re: WebView/Browser: How to browse files from the sdcard?

2009-01-11 Thread Mariano Kamp
Hey Mark.

 Mariano Kamp wrote:
  OMG. That is such a blow. I didn't read anything like that in the
  WebView documentation.

 I didn't say WebView. I said Browser. Browser != WebView.

Sorry, I know, I didn't want to imply otherwise.

 Any idea how to work around that?

 Writing a ContentProvider to serve your content appears to be the
 standard answer. I haven't used that technique myself as yet, though.

 I don't see how that should work?
Wouldn't that be the same as the FileContentProvider? How would WebView
learn about this provider.

Anyway, thanks for taking the time to think answer my question.

Cheers,
Mariano

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



[android-developers] Re: WebView/Browser: How to browse files from the sdcard?

2009-01-11 Thread Mark Murphy

Mariano Kamp wrote:
 I don't see how that should work?
 Wouldn't that be the same as the FileContentProvider? 

I cannot find a FileContentProvider class in the SDK or SDK samples. I
see where there is one in the source code, and, yes, I think that's the
basic idea.

 How would WebView learn about this provider.

I believe you feed it a URL, like:

content://your.provider.here/path/to/something.html

But, again, I have not tried this myself, though I recall seeing some
posts in this group, and maybe a blog post, covering this technique to
some degree.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
Android Training in Sweden -- http://www.sotrium.com/training.php

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



[android-developers] Re: WebView/Browser: How to browse files from the sdcard?

2009-01-11 Thread Mariano Kamp
Once again, thanks.

I found this tutorial:
http://www.anddev.org/tutproviding_data_in_a_contentprovider-t4073.html
and will try that.

I checked that the ContentProvider is called from the Browser... So the rest
should work.

On Sun, Jan 11, 2009 at 7:58 PM, Mark Murphy mmur...@commonsware.comwrote:


 Mariano Kamp wrote:
  I don't see how that should work?
  Wouldn't that be the same as the FileContentProvider?

 I cannot find a FileContentProvider class in the SDK or SDK samples. I
 see where there is one in the source code, and, yes, I think that's the
 basic idea.

  How would WebView learn about this provider.

 I believe you feed it a URL, like:

 content://your.provider.here/path/to/something.html

 But, again, I have not tried this myself, though I recall seeing some
 posts in this group, and maybe a blog post, covering this technique to
 some degree.

 --
 Mark Murphy (a Commons Guy)
 http://commonsware.com
 Android Training in Sweden -- http://www.sotrium.com/training.php

 


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