Code example for AssetManager: Using file assets

Methods: open

0
    } 
 
    public static String loadShader(String file, Context context) {
        try { 
            AssetManager assetManager = context.getAssets();
            InputStream ims = assetManager.open(file);
 
            String re = convertStreamToString(ims);
            ims.close();
            return re;
        } catch (Exception e) {
            e.printStackTrace();
        } 
 
        return ""; 
    } 
 
    public static String convertStreamToString(java.io.InputStream is) {
        java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A");
        return s.hasNext() ? s.next() : "";
Experience pair programming with AI  Get Codota for Java