read file from assets

前端 未结 18 2236
终归单人心
终归单人心 2020-11-21 22:47
public class Utils {
    public static List getMessages() {
        //File file = new File(\"file:///android_asset/helloworld.txt\");
        AssetMan         


        
18条回答
  •  太阳男子
    2020-11-21 23:31

    getAssets() method will work when you are calling inside the Activity class.

    If you calling this method in non-Activity class then you need to call this method from Context which is passed from Activity class. So below is the line by you can access the method.

    ContextInstance.getAssets();
    

    ContextInstance may be passed as this of Activity class.

提交回复
热议问题