android-assets

Difference between /res and /assets directories

不羁的心 提交于 2019-11-26 11:32:54
I know that files in the res directory are accessible from R.class while assets behaves like a file system, but I would like to know, in general, when it's best to use one and the other. Can anyone help me in knowing the real differences between res and assets? With resources, there's built-in support for providing alternatives for different languages, OS versions, screen orientations, etc., as described here . None of that is available with assets. Also, many parts of the API support the use of resource identifiers. Finally, the names of the resources are turned into constant field names that

how to reference an asset in a library project

谁都会走 提交于 2019-11-26 09:29:49
问题 In a class belonging to a Library project I call: webview.loadUrl(\"file:///android_asset/info.html\", null); Unfortunately, this only works if I duplicate the file info.html into the Application\'s project asset folder as well. Is there a way to tell an Android library code: \"look for this file in the library\'s assets folder, not in the application\'s assets folder\" ? 回答1: From the Android Docs: Library projects cannot include raw assets The tools do not support the use of raw asset files

How to get the android Path string to a file on Assets folder?

两盒软妹~` 提交于 2019-11-26 06:34:38
问题 I need to know the string path to a file on assets folder, because I\'m using a map API that needs to receive a string path, and my maps must be stored on assets folder This is the code i\'m trying: MapView mapView = new MapView(this); mapView.setClickable(true); mapView.setBuiltInZoomControls(true); mapView.setMapFile(\"file:///android_asset/m1.map\"); setContentView(mapView); Something is going wrong with \"file:///android_asset/m1.map\" because the map is not being loaded. Which is the

When should I use the assets as opposed to raw resources in Android?

此生再无相见时 提交于 2019-11-26 06:04:49
问题 I\'m in the mid of my studies in the Android world, and I just covered the Assets and Raw resources. I\'m trying to understand the reason for using Raw resources vs. Assets. They both provide with an uncompiled resource input stream. It seems that Assets provide much more flexibility and functionality then Raw resources. a. You can create folder structure under Assets and not under Raw b. You can list all resources dynamically in the assets folder and not in the Raw folder. So, why would I

Loading existing .html file with android WebView

亡梦爱人 提交于 2019-11-26 02:30:06
问题 I did try samples, demos from Google codes and other resources with WebView , but when i try to do it in my own code, it doesn\'t work for me. I want to load myfile.html which i put in assets folder, and using: private WebView myWebView; myWebView.loadUrl(\"file:///android_assets/myfile.html\"); On emulator shows error The web page at file:///android_assets/myfile.html could not be loaded as: The requested file was not found. /android_assets/myfile.html When i put that file to res/raw/ folder

Difference between /res and /assets directories

瘦欲@ 提交于 2019-11-26 02:27:48
问题 I know that files in the res directory are accessible from R.class while assets behaves like a file system, but I would like to know, in general, when it\'s best to use one and the other. Can anyone help me in knowing the real differences between res and assets? 回答1: With resources, there's built-in support for providing alternatives for different languages, OS versions, screen orientations, etc., as described here. None of that is available with assets. Also, many parts of the API support

Play audio file from the assets directory

帅比萌擦擦* 提交于 2019-11-26 01:06:55
问题 I have the following code: AssetFileDescriptor afd = getAssets().openFd(\"AudioFile.mp3\"); player = new MediaPlayer(); player.setDataSource(afd.getFileDescriptor()); player.prepare(); player.start(); The problem is that, when I run this code, it starts playing all the audio files in the assets directory, in alphabetical order instead of just playing the audio file I requested. What am I doing wrong? Is there a better way to play audio files from the assets directory? Follow-up question: Is

Play audio file from the assets directory

谁说胖子不能爱 提交于 2019-11-26 01:02:23
I have the following code: AssetFileDescriptor afd = getAssets().openFd("AudioFile.mp3"); player = new MediaPlayer(); player.setDataSource(afd.getFileDescriptor()); player.prepare(); player.start(); The problem is that, when I run this code, it starts playing all the audio files in the assets directory, in alphabetical order instead of just playing the audio file I requested. What am I doing wrong? Is there a better way to play audio files from the assets directory? Follow-up question: Is there a difference between keeping audio files in the assets directory and keeping them in the res/raw

Where do I place the 'assets' folder in Android Studio?

荒凉一梦 提交于 2019-11-25 22:31:24
问题 I am confused about the assets folder. It doesn\'t come auto-created in Android Studio, and almost all the forums in which this is discussed talk about Eclipse. How can the Assets directory be configured in Android Studio? 回答1: Since Android Studio uses the new Gradle-based build system, you should be putting assets/ inside of the source sets (e.g., src/main/assets/ ). In a typical Android Studio project, you will have an app/ module, with a main/ sourceset ( app/src/main/ off of the project