android-assets

How to get file read line by line

◇◆丶佛笑我妖孽 提交于 2019-11-27 02:36:58
问题 I have a file containing text in separate line. I want to display line first, and then if I press a button, the second line should be displayed in the TextView and the first line should disappear. Then, if I press it again, the third line should be displayed and so on. Should I have to use TextSwitcher or anything else? How can I do that? 回答1: You tagged it as "android-assets" so I'm going to assume your file is in the assets folder. Here: InputStream in; BufferedReader reader; String line;

how to reference an asset in a library project

烂漫一生 提交于 2019-11-27 00:55:27
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" ? kabuko 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

How to determine the Absolute path for specific file from Assets?

喜夏-厌秋 提交于 2019-11-26 23:30:44
问题 In an iPhone Application, I just write one line to get the complete path for a specific file ( as below ). NSString *strPath=[[NSBundle mainBundle] pathForResource:@"myjavascript" ofType:@"js"]; My question is How to get the complete path for a specific file which is located under Assets folder in Android . Sample Image. 回答1: Assets are compiled into .apk file (which basically is zip file). You can't get system path into zip file. You have to manually unzip .apk to some folder and get file

Updating prepopulated database in Android

余生颓废 提交于 2019-11-26 20:51:29
问题 I lost last 3 hours trying to do this. Im making an app that will ship with a DB filled with populated tables that would not change on clients devices. I managed to do this by putting it in the assets folder and copying it as a stream of bytes to the appropriate data folder on the phone. Problem is when I wish to update the database, I cant get it to work. I delete the DB in data folder on phone (from code), but copying the new database always fails, or the copied DB has the appropriate size

Accessing a font under assets folder from XML file in Android

我与影子孤独终老i 提交于 2019-11-26 20:32:04
问题 I am trying to do a application-wide font change and creating a style file to do so. In this file (below) I just want to change typeface value of TextAppearance style of Android. <?xml version="1.0" encoding="utf-8"?> <resources> <style name="NightRiderFont" parent="@android:style/TextAppearance"> <item name="android:typeface"> /***help need here***/ </item> </style> </resources> However font is in "assets/fonts/". How can I access this font, so I can use that style as a theme to get rid of

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

[亡魂溺海] 提交于 2019-11-26 18:43:07
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 correct string path file to the file m1.map stored on my assets folder? Thanks EDIT for Dimitru: This code doesn

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

我们两清 提交于 2019-11-26 17:04:00
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 use Raw resources in Android? The main differences between the raw folder and the Assets folder. Since raw

DB File in Assets Folder. Will it be Updated?

喜你入骨 提交于 2019-11-26 13:03:54
问题 I\'m new to the Android SQLite whole thing. This is what I have: I have db.sqlite in my assets folder. The intent of the db is to READ ONLY. The user will not write to it. When the app gets updated, the db.sqlite will be replaced be a new db (I\'ll delete the old file from the project and add the new one). What I\'m concerned about is: Will the old db file gets deleted? (that\'s what I want; replacing the old one with the new one) Why ask? Because when I debug my app, each time I update the

How to access files under assets folder of other apk&#39;s?

天大地大妈咪最大 提交于 2019-11-26 12:47:04
问题 When we browse any apk we found there is one folder named assets. Now I want to access that folder programatically. so how should I proceed for that? (Input for the program will be apk file/just app name). 回答1: This will list all the files in the assets folder: AssetManager assetManager = getAssets(); String[] files = assetManager.list(""); This to open a certian file: InputStream input = assetManager.open(assetName); 回答2: If you want to access file from assets folder use the following code:

Loading existing .html file with android WebView

拟墨画扇 提交于 2019-11-26 11:40:54
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 and using: myWebView.loadUrl("file:///android_res/raw/myfile.html"); then only emulator android 2.2 API