List of usage examples for android.content.res AssetManager list
public @Nullable String[] list(@NonNull String path) throws IOException
From source file:com.group7.dragonwars.MapSelectActivity.java
@Override protected final void onStart() { super.onStart(); if (mapInfo.size() == 0) { AssetManager assman = getAssets(); ListView mapList = (ListView) this.findViewById(R.id.mapList); try {//from w w w.j a v a 2 s . c om String[] files = assman.list("maps"); for (int i = 0; i < files.length; ++i) { String path = "maps/" + files[i]; BasicMapInfo info = MapReader.getBasicMapInformation(path, this); mapInfo.add(info); } String[] displayInfo = new String[mapInfo.size()]; for (Integer i = 0; i < mapInfo.size(); i++) { displayInfo[i] = mapInfo.get(i).getDesc(); } ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, displayInfo); mapList.setAdapter(adapter); } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } } }
From source file:com.orange.ocara.model.RuleSetLoaderImpl.java
private void PictosFolder(AssetManager assetManager) throws IOException { String[] assetsList = assetManager.list(PICTOS_FOLDER); for (String asset : assetsList) { if (isPngFile(asset) | isJpgFile(asset) | isGifFile(asset)) { Timber.i("pictos to install : %s", asset); File rulesetDirPicto = installRuleset(PICTOS_FOLDER); File target = new File(rulesetDirPicto, asset); FileUtils.copyInputStreamToFile(assetManager.open(PICTOS_FOLDER + "/" + asset), target); }// w ww . j a v a2 s.c om } }
From source file:com.orange.ocara.model.RuleSetLoaderImpl.java
private void imagesFolder(AssetManager assetManager) throws IOException { String[] assetsList = assetManager.list(IMAGES_FOLDER); for (String asset : assetsList) { if (isPngFile(asset) | isJpgFile(asset) | isGifFile(asset)) { Timber.i("images to install : %s", asset); File rulesetDirImage = installRuleset(IMAGES_FOLDER); File target = new File(rulesetDirImage, asset); FileUtils.copyInputStreamToFile(assetManager.open(IMAGES_FOLDER + "/" + asset), target); }/* w w w .j a va 2s .c om*/ } }
From source file:org.phoneremotecontrol.app.http.HttpServerService.java
private boolean copyAssetFolder(AssetManager assetManager, String fromAssetPath, String toPath) { try {/*from w w w. ja v a2 s .c o m*/ String[] files = assetManager.list(fromAssetPath); new File(toPath).mkdirs(); boolean res = true; for (String file : files) if (file.contains(".")) res &= copyAsset(assetManager, fromAssetPath + "/" + file, toPath + "/" + file); else res &= copyAssetFolder(assetManager, fromAssetPath + "/" + file, toPath + "/" + file); return res; } catch (Exception e) { e.printStackTrace(); return false; } }
From source file:com.gnuroot.rsinstaller.RSLauncherMain.java
/** * Renames assets from .mp3 to .tar.gz./*from ww w. j a va 2s .co m*/ * @param packageName */ private void copyAssets(String packageName) { Context friendContext = null; try { friendContext = this.createPackageContext(packageName, Context.CONTEXT_IGNORE_SECURITY); } catch (NameNotFoundException e1) { return; } AssetManager assetManager = friendContext.getAssets(); String[] files = null; try { files = assetManager.list(""); } catch (IOException e) { Log.e("tag", "Failed to get asset file list.", e); } for (String filename : files) { Log.i("files ", filename); InputStream in = null; OutputStream out = null; try { in = assetManager.open(filename); filename = filename.replace(".mp3", ".tar.gz"); out = openFileOutput(filename, MODE_PRIVATE); copyFile(in, out); in.close(); in = null; out.flush(); out.close(); out = null; } catch (IOException e) { Log.e("tag", "Failed to copy asset file: " + filename, e); } } }
From source file:com.orange.ocara.model.RuleSetLoaderImpl.java
@Override public void initialize() { final AssetManager assetManager = context.getAssets(); try {// www . j a va 2 s . c om String[] assetsList = assetManager.list(RULESETS_FOLDER); for (String asset : assetsList) { if (isJsonFile(asset)) { Timber.i("ruleset to install : %s", asset); File rulesetDir = installRuleset(asset); File target = new File(rulesetDir, asset); FileUtils.copyInputStreamToFile(assetManager.open(RULESETS_FOLDER + "/" + asset), target); } } } catch (IOException e) { e.printStackTrace(); } try { PictosFolder(assetManager); } catch (IOException e) { e.printStackTrace(); } try { imagesFolder(assetManager); } catch (IOException e) { e.printStackTrace(); } }
From source file:net.bible.service.readingplan.ReadingPlanDao.java
/** look in assets/readingplan and sdcard/jsword/readingplan for reading plans and return a list of all codes */// w w w . j a va 2s.c o m private List<String> getAllReadingPlanCodes() throws IOException { Resources resources = BibleApplication.getApplication().getResources(); AssetManager assetManager = resources.getAssets(); List<String> allCodes = new ArrayList<String>(); String[] internalPlans = assetManager.list(READING_PLAN_FOLDER); allCodes.addAll(getReadingPlanCodes(internalPlans)); String[] userPlans = USER_READING_PLAN_FOLDER.list(); allCodes.addAll(getReadingPlanCodes(userPlans)); return allCodes; }
From source file:com.bellman.bible.service.readingplan.ReadingPlanDao.java
/** * look in assets/readingplan and sdcard/jsword/readingplan for reading plans and return a list of all codes *///from w ww . j a v a 2s . c o m private List<String> getAllReadingPlanCodes() throws IOException { Resources resources = CurrentActivityHolder.getInstance().getApplication().getResources(); AssetManager assetManager = resources.getAssets(); List<String> allCodes = new ArrayList<String>(); String[] internalPlans = assetManager.list(READING_PLAN_FOLDER); allCodes.addAll(getReadingPlanCodes(internalPlans)); String[] userPlans = USER_READING_PLAN_FOLDER.list(); allCodes.addAll(getReadingPlanCodes(userPlans)); return allCodes; }
From source file:com.littlepancake.glpk.GLPKModLangFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.activity_glpktest, container, false); problemEntryEditText = (EditText) v.findViewById(R.id.problemEntryEditText); buttonSolve = (Button) v.findViewById(R.id.buttonSolve); buttonClear = (Button) v.findViewById(R.id.buttonClear); buttonComments = (Button) v.findViewById(R.id.buttonComments); buttonSolve.setOnClickListener(this); buttonClear.setOnClickListener(this); buttonComments.setOnClickListener(this); Resources res = getResources(); AssetManager am = res.getAssets(); String fileList[] = null;/* w w w . j a v a 2s . co m*/ try { fileList = am.list(""); } catch (IOException e) { e.printStackTrace(); } if (fileList != null) { for (int i = 0; i < fileList.length; i++) { Log.d(tag, fileList[i]); } } return v; }
From source file:com.zetterstrom.android.soundboarder.fragments.SoundboardFragment.java
public void createSounds(int position) { mSounds = new ArrayList<Sound>(); String assetFolder = ""; switch (position) { case 0:/* w ww . ja v a2s.c o m*/ assetFolder = "arnold"; break; case 1: assetFolder = "ben_stiller_dodgeball"; break; case 2: assetFolder = "borat"; break; case 3: assetFolder = "charlie_sheen"; break; case 4: assetFolder = "family_guy"; break; case 5: assetFolder = "kramer"; break; case 6: assetFolder = "napolean_dynamite"; break; case 7: assetFolder = "samuel_jackson"; break; case 8: assetFolder = "shammy"; break; case 9: assetFolder = "super_troopers"; break; case 10: assetFolder = "tony_soprano"; break; default: return; } Sound s; AssetManager am = getActivity().getAssets(); try { String[] allSounds = am.list(assetFolder); for (String soundName : allSounds) { s = new Sound(); s.setDescription(StringParser.splitCamelCase(soundName)); s.setAssetDescription(assetFolder + "/" + soundName); mSounds.add(s); } } catch (IOException e) { e.printStackTrace(); } }