How to access a file from asset/raw directory

后端 未结 5 1142
南笙
南笙 2020-11-30 12:34

with this below code i\'m trying to access the file which is stored in asset/raw folder, but getting null and

E/ERR: file:/android         


        
5条回答
  •  伪装坚强ぢ
    2020-11-30 12:39

    Assets and resources are files on your development machine. They are not files on the device.

    For assets, use open() on AssetManager to get an InputStream on your asset.

    Also, FWIW:

    • Uri.parse("file:///android_asset/raw/default_book.txt").toString() is pointless, as it gives you the same string that you started with

    • file:///android_asset/ only works for WebView

提交回复
热议问题