Where are files stored on phone?

Philipp

Member
Licensed User
Longtime User
For a webview I added a html file with some pictures. I thought the pictures would be shown with the html but are not displayed. The files are in the same directory as the html.

Where does b4a store the files on the phone? Is the html file stored at a different place as the pictures?

Sent from my GT-P1000 using Tapatalk 2
 

Philipp

Member
Licensed User
Longtime User
I saw the files in the cache folder, but hoped they were not. I hoped that I could have the html file and the pics in one place and that they would keep their original names.

In eclipse I would simply put all the files in the assets folder and all is good.

Soooooo?

Gesendet von meinem GT-P1000 mit Tapatalk 2
 
Upvote 0

JonPM

Well-Known Member
Licensed User
Longtime User
Directly from the docs...:

LoadHtml (Html As String)
Loads the given Html.
Example:
WebView1.LoadHtml("<html><body>Hello world!</body></html>")
You can use "file:///android_asset" to access files added with the file manager:
WebView1.LoadHtml("<html><body><img src='file:///android_asset/someimage.jpg'/></body></html>")
Note that files added with the file manager should be accessed with a lower cased name.
 
Upvote 0

margret

Well-Known Member
Licensed User
Longtime User
This is code I use and it works fine:

B4X:
Sub MyHelp_Click
   'Add following line to Sub Globals
   'Dim myw As WebView
   myw.Initialize("myw")
   myss="file:///android_asset/help.htm"
   rr.Target = myw
      rr.Target = rr.RunMethod("getSettings")
      rr.RunMethod2("setPluginsEnabled", False, "java.lang.boolean")
   myw.JavaScriptEnabled = False
   myw.ZoomEnabled = False
   myw.Visible = True
   myw.LoadUrl(myss)
End Sub
 
Upvote 0

Philipp

Member
Licensed User
Longtime User
Hmm, I have this line:
B4X:
webpage = File.GetText(File.DirAssets, "test.html")

I even renamed all the files which were exported and renamed automatically to 'Clipboard-Image-1.png' to 'clipboard_image_1.png', edited the html accordingly, checked that all worked in the normal browser and then reimported into the files directory, but no, images don't show up.

I'll try setting the path directly like you did margret. If I could find - besides the cache-directory - where I can actually find the files, that would maybe help.

I have my tablet rooted, so if it's there I should be able to look at the location.
 
Upvote 0

Philipp

Member
Licensed User
Longtime User
ok, I got it, 'LoadUrl' does it.

B4X:
webpage = "file:///android_asset/test.html"
WebView1.LoadHtml(webpage)
works

B4X:
webpage = File.GetText(File.DirAssets, "test.html")
WebView1.LoadHtml(webpage)
doesn't show the images.

Why????
 
Upvote 0

Philipp

Member
Licensed User
Longtime User
Can somebody explain me why I need a "file://... " to see a webpage on the external path?
B4X:
webpage = "file://" & File.DirDefaultExternal & "/UnZIPFiles/test.html"

Without file:// WebView wasn't able to display the html-file although the path was shown correctly.
 
Upvote 0

Philipp

Member
Licensed User
Longtime User
Ah, ok. Without file prefix webview assumes a http address? Thx.

Gesendet von meinem GT-P1000 mit Tapatalk 2
 
Upvote 0
Top