android-assets

file:///android_asset does not work

爷,独闯天下 提交于 2019-12-12 16:18:01
问题 I store the images in assets/img/categories folder and trying to load them with this code: ImageLoader.getInstance().displayImage(String.format("file:///android_asset/img/categories/%d.JPG", category.getId()), mImageIv); It seems to be OK, but does not work: E/ImageLoader(28790): /android_asset/img/categories/9.JPG: open failed: ENOENT (No such file or directory) E/ImageLoader(28790): java.io.FileNotFoundException: /android_asset/img/categories/9.JPG: open failed: ENOENT (No such file or

Android Media Player: Start called in state 4 error(-38,0)

心不动则不痛 提交于 2019-12-12 07:25:35
问题 This is the code am using to fetch a file name(.mp3) dynamically from some other class as am having many mp3 files in my assets folder: playAudioButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { FileName audio=new FileName(); String audioName=audio.getAudioName(count).toString(); if(audioName=="NO Audio") { Toast.makeText(getApplicationContext(), "No Audio for this page", Toast.LENGTH_SHORT).show(); } else { try { afd=getAssets().openFd(audioName + "

Update json file in android assets folder

烂漫一生 提交于 2019-12-12 03:47:33
问题 I visualize my app's data using google charts in the html file kept in assets folder of my android app. The html file is loaded in android WebView. I use Firebase Cloud Messaging to silently update my android app's data. Since the app needs to work offline too i need to persist the data. I can save it in shared preferences but i don't see a way for my javascript in html file to read android's shared preferences. So, when the payload is received i want to update a .json file (in the assets

Can anyone access what is inside Assests folder?

廉价感情. 提交于 2019-12-12 02:08:19
问题 I want to develop an application for some company. The application is mainly a search tool in a specific database. I have two ways to develop this application: Include the DB file into the assest folder and use it. search using API. (My search tool has an API. And you can search the DB using the browser). I prefer the first option. The problem is my customer want their DB files to not be accessible by unauthorized parties. They are very serious about this issue. If I developed the app using

How to apply CSS into WebView for remote html(url)?

混江龙づ霸主 提交于 2019-12-11 19:24:13
问题 I have a web page for example "example.google.com/login?" I have loaded this url into the WebView using WebView.loadUrl() method. I have the css for this webpage and saved it in under the assets folder. Now I want to apply custom css for this remote html. How do I achieve that? I have used loadDataWithBaseurl() but it didn't help. How can I fix this problem? Is css only applying for a local html file that is stored in assets folder? 回答1: Had the same issue here, but worked around the issue! 1

copy images from assest to sd card on install android application

[亡魂溺海] 提交于 2019-12-11 17:50:50
问题 i have some images should be displayed in the Application, the Q. is how to copy the images i am putting in the assets folder in the code to a folder under the SC card of the user on install the application on the phone 回答1: Try with this, private void copyAssets() { AssetManager assetManager = getAssets(); String[] files = null; try { files = assetManager.list(""); } catch (IOException e) { Log.e("tag", e.getMessage()); } for(String filename : files) { InputStream in = null; OutputStream out

Copying database from the asset folder

末鹿安然 提交于 2019-12-11 15:13:05
问题 I am failed in accessing the database from my asset folder. I have a db in my asset folder . I try to add that in my project . I can see that db in the logcat->data->my project->database->mydbname .When i pull that db and open with sqliter browser then i don't see the data that is supposed to be there. Here is my code : package com.example.dbhelper; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.sql

Android getAssets() method throws NullPointerException

时间秒杀一切 提交于 2019-12-11 14:37:59
问题 I'm trying to get assets of my app from Service and i get nullpointexception. I found few articles about it.but i don't get where my mistake. Where is the code: public class OCRService extends IntentService{ private static final String TAG = "OCRService"; public static final String DATA_PATH = Environment.getExternalStorageDirectory().toString() + "/SimpleAndroidOCR/"; public OCRService() { super("OCRService"); String path = new String(DATA_PATH + "tessdata/"); File dir = new File(path); if (

Get resource identifier (resId) of multiple images from asset or raw folder to an int array

。_饼干妹妹 提交于 2019-12-11 13:12:41
问题 I have 100+ images to load into a listView , and I am trying to store all the resId into an int[] . I can done it from drawable by using the below code Field[] ID_Fields = R.drawable.class.getFields(); resArray = new int[ID_Fields.length]; for(int i = 0; i < ID_Fields.length; i++) { try { resArray[i] = ID_Fields[i].getInt(null); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block

How to load a lot of files from assets asynchronously?

回眸只為那壹抹淺笑 提交于 2019-12-11 11:31:39
问题 I know that it has similar topics. But in each topic we are open InputStream before task will be run and in new thread load data. But I have 90 asset files. Is this a single way to create 90 AsyncTask ? Can I get access to main thread in inBackground() method to get assets and open new InputStream ? Just in my case if I'll create 90 tasks I also need to synchronize their order of launch and finish. I need a point of synchronization where my AsyncTask will be wait the main thread. 回答1: My