android-assets
WebView on Android ICS, iframe problems with android_assets
Sirs, I had the same problem when using Phonegap (Apache Cordova) and IFrames in Android Ice Cream Sandwich (4.0.3). To solve this problem, I had to edit Apache Cordova Source Code. I changed the org.apache.cordova.CordovaWebViewClient.java file, and commented this part of the code, and included the last line (return false;). So it now looks like … Read more
Read a Text asset(text file from assets folder) as a String in Kotlin (Android)
I found this in a youtube video. Here is the link https://www.youtube.com/watch?v=o5pDghyRHmI val file_name = “qjsonfile.json” val json_string = application.assets.open(file_name).bufferedReader().use{ it.readText() } Saves the JSON or text to the string json_string.
how to reference an asset in a library project
This answer is out of date, the gradle build system and AAR files support assets. From the Android Docs: Library projects cannot include raw assets The tools do not support the use of raw asset files (saved in the assets/ directory) in a library project. Any asset resources used by an application must be stored … Read more
How to get the android Path string to a file on Assets folder?
AFAIK the files in the assets directory don’t get unpacked. Instead, they are read directly from the APK (ZIP) file. So, you really can’t make stuff that expects a file accept an asset ‘file’. Instead, you’ll have to extract the asset and write it to a seperate file, like Dumitru suggests: File f = new … Read more
Loading existing .html file with android WebView
ok, that was my very stupid mistake. I post the answer here just in case someone has the same problem. The correct path for files stored in assets folder is file:///android_asset/* (with no “s” for assets folder which i was always thinking it must have a “s”). And, mWebView.loadUrl(“file:///android_asset/myfile.html”); works under all API levels. I … Read more
Play audio file from the assets directory
player.setDataSource(afd.getFileDescriptor(),afd.getStartOffset(),afd.getLength()); Your version would work if you had only one file in the assets directory. The asset directory contents are not actually ‘real files’ on disk. All of them are put together one after another. So, if you do not specify where to start and how many bytes to read, the player will read up … Read more