Android Question (SOLVED)Access cache files from webview using WebViewAssetLoader API 30

Ferdari

Active Member
Licensed User
Longtime User
Hi everyone,

previously i was using a webview for previewing content from cache (eg.: image), Dir has File.DirInternalCache path:
WV.LoadHtml($"<img src="${xui.FileUri(Dir, FileName)}" style="width: 100%;height: auto;"/>"$)

Do you know the exact path to load file from cache using WebViewAssetLoader for API 30
"https://appassets.androidplatform.net/public/shared/packets/"& subDir. &"/"& FileName" 'This works perfect from internal

Already tried:
"https://appassets.androidplatform.net/public/cache/packets/"& subDir. &"/"& FileName"

The files are there in the exact path and subfolders ("cache/packets")

Help would be very appreciated.
 

drgottjr

Expert
Licensed User
Longtime User
not available (via the library). the api does hint at a custom path which needs to be registered. dirinternalcache might be handled that way. i'll take a look.
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
when i try to add the cache directory to the path, there is an exception indicating that the
cache directory "doesn't exist under an allowed app internal storage directory".

from android's documentation: Exposing the entire data or cache directory is not permitted,
to avoid accidentally exposing sensitive application files to the web.

also, and perhaps more importantly, the cache directory can be deleted by the o.s. when needed.
so your app could fail at unexpected times.
 
Upvote 0

Ferdari

Active Member
Licensed User
Longtime User
when i try to add the cache directory to the path, there is an exception indicating that the
cache directory "doesn't exist under an allowed app internal storage directory".

from android's documentation: Exposing the entire data or cache directory is not permitted,
to avoid accidentally exposing sensitive application files to the web.

also, and perhaps more importantly, the cache directory can be deleted by the o.s. when needed.
so your app could fail at unexpected times.
Oh, thanks for your time,

as my app downloads a lot of data, most temporary data are stored in cache, if not used, it can be cleaned by system or app.

I solved copying files from Cache to Internal and then displaying previews in Webview.

Thanks again @drgottjr for your great library and support.
 
Upvote 0
Top