How to access application internal storage from html file in Assets folder Xamarin.android?

263 Views Asked by At

I have to load a .svf file into my WebView. I have a HTML file in my Assets folder and the .svf file and all the related files also included in the same folder. I am loading my .svf file ussing a Javascript code inside HTML file and this works without any issue. Following is my Javascript code snippet to load the .svf file.

<script>
const MODEL_URL = './Models/Model1/output.svf';
        Autodesk.Viewing.Initializer({ env: 'Local' }, async function () {
            const viewer = new Autodesk.Viewing.GuiViewer3D(document.getElementById('preview'));
            viewer.start(MODEL_URL);
        }); 
</script>

And I load the html page to the Webviewas wbMain.LoadUrl("file:///android_asset/html/index.html");

Then I moved my .svf files into Application Internal storage./storage/emulated/0/Android/data/com.companyname.MyTestApp/files/Models/output.svf and changed HTML code MODEL_URL like this. const MODEL_URL = 'file:///storage/emulated/0/Android/data/com.companyname.MyTestApp/files/Models/output.svf';

But now the file is not loading. My HTML file is still insidethe Assets folder. How can I achieve this? I need to load those files from the internal storage through the javascript code in html file.

Thanks in advance.

UPDATE 1

My WebView has following file access permissions.

wbMain.Settings.AllowFileAccess = true;
wbMain.Settings.AllowFileAccessFromFileURLs = true;
wbMain.Settings.AllowUniversalAccessFromFileURLs = true;
0

There are 0 best solutions below