assets 在包中是没有path的

本文探讨了在Android应用中获取资产(assets)目录路径的方法。虽然设备上并不存在资产目录的路径,但可以通过AssetManager来访问资产文件。文章讨论了资产目录与raw资源目录的区别,并提出了解决文件大小限制的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


ZZZZZhttp://stackoverflow.com/questions/6678951/how-do-i-get-the-absolute-path-of-assets-directory-in-android

There is no "path of the assets directory" on the device.

I just want the path of the assets directory which I want to use as a variable throughout my app.

There is no "path of the assets directory" on the device.

I know we can refer a file in the "assets" directory using AssetManager, but I don't want to refer a file as of now, I just want the path of the assets directory.

There is no "path of the assets directory" on the device.

Can anybody help me with this?

No, because there is no "path of the assets directory" on the device. Please use AssetManager to retrieve an InputStream to your assets as needed.

Since android has a file size restriction on files inside raw directory, I will be placing my files in assets directory, and during runtime, I would be retrieving them as need

The "restriction" is the same for assets, AFAIK. The usual way to circumvent the "restriction" is to give the file an extension that Android's build tools will not try to compress (.mp3 works IIRC).

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值