Java tutorial
//package com.java2s; import android.content.Context; import android.content.res.AssetManager; import android.graphics.Typeface; import android.util.Log; import java.io.IOException; import java.util.HashMap; public class Main { private static HashMap<String, Typeface> fonts; public static void createFonts(Context context, String path) { fonts = new HashMap<>(); try { String[] listOfFonts = listAssetFiles(path, context); for (String s : listOfFonts) { Typeface typeface = Typeface.createFromAsset(context.getAssets(), path + "/" + s); fonts.put(s.substring(0, s.lastIndexOf(".")), typeface); Log.d("PKFontUtils", "fonts" + s.substring(0, s.lastIndexOf("."))); } } catch (IOException e) { e.printStackTrace(); } } private static String[] listAssetFiles(String path, Context applicationContext) throws IOException { AssetManager assetManager = applicationContext.getAssets(); String[] listOfFonts = assetManager.list(path); return listOfFonts; } }