How to get access monkey://data/ from native code?
Monkey Forums/Monkey Programming/How to get access monkey://data/ from native code?| 
 | ||
| Android: I tried to use monkey protocol to load html page from data folder into webview _webView.loadUrl("monkey://data/Index.htm");webview shows 404 error message. Read internet and change code to use file:// protocol _webView.loadUrl("file:///android_asset/monkey/Index.htm");It works but will has some troubles with security. How to get access to files under data folder in iOS and WP/WinRT targets? | 
| 
 | ||
| PathToFilePath convert first. | 
| 
 | ||
| hsutuo wrote:  PathToFilePath convert first.  Hmm, its source 	String PathToFilePath( String path ){
		return "";
	}
 | 
| 
 | ||
| i believe this webview will show extra window. did you try OpenUrl with local html data? | 
| 
 | ||
| Markus wrote:  i believe this webview will show extra window.  I create webview in the current layout, it doesn't open new window when webviewclient released. Markus wrote:  did you try OpenUrl with local html data?  I didn't. Do you mean that I can to view java code for this call? | 
| 
 | ||
| nikoniko wrote:  I didn't. Do you mean that I can to view java code for this call?  App crashes on OpenUrl("monkey://data/Index.htm") line and OpenUrl("file:///adroid_asset/monkey/Index.htm") too. | 
| 
 | ||
|  -- PathToFilePath convert first. Hmm, its source This one is the native PathToFilePath method. String PathToFilePath( String path ){
		if( !path.startsWith( "monkey://" ) ){
			return path;
		}else if( path.startsWith( "monkey://internal/" ) ){
			File f=_activity.getFilesDir();
			if( f!=null ) return f+"/"+path.substring(18);
		}else if( path.startsWith( "monkey://external/" ) ){
			File f=Environment.getExternalStorageDirectory();
			if( f!=null ) return f+"/"+path.substring(18);
		}
		return "";
	}You'll find it in "MonkeyXPro-Versionnumber-/targets/android/modules/native/androidgame.java" Same goes for iOS and other. OpenURL() doesn't call PathToFilePath. So monkey://data will result in an error. Because monkey://data/whatever isn't a valid file path in java. This native java code should work. Haven't tested it. File f=BBAndroidGame.AndroidGame().GetActivity().getFilesDir(); if( f!=null ) f+"/Index.htm"; // Index.htm should be inside your data folder _webView.loadUrl(f); | 
| 
 | ||
| Ironstorm Thanks! |