I'm working around a web service using nanohttpd. I've following files in assets folder (Android Studio):
All works properly including the direct reference to JQuery:
<script src="http://code.jquery.com/jquery-latest.min.js "></script>
But actually, I will not have Internet connection when I will use the server, so I need the local reference to assets folder.
I tried the simple way but doesn't work:
<script src="jquery_1.11.3.min.js"></script>
I've seen other similiar question (Link) but I can't understand the answer :(.
Can you help me with Jquery Script reference?
Thank you and sorry for my english.
You should use getResources().getAssets() code to access file from assets folder. For example:
private Response getFromAssets(String filename) {
InputStream fis;
try {
fis = this.getResources().getAssets().open(filename);
} catch (IOException e) {
return new Response(Response.Status.OK, "text/plain", "Internal Error: " + e.getMessage());
}
return new Response(Response.Status.OK, /*MIME-type*/ "application/javascript", fis);
}