Android:将图像存储到项目目录(文件)中?
我想将我的位图图像存储到项目目录中。我如何访问我的项目文件夹或者我的项目文件夹的地址是什么?
I want to store my Bitmap image into project directory. How can I have access to my project folder or what is the address of my project folder?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须将图像放入
res/drawable
文件夹中。然后,您可以使用以下方式访问它们:R.drawable.name_of_image
(对于name_of_image.png
或name_of_image.jpg
)。如果您想通过原始名称访问它们,最好将它们保存在
assets
文件夹中。然后,您可以使用AssetManager
访问它们:如果您想保存以编程方式创建的图像,您可以执行以下操作:
您无法将其保存到项目目录中。我建议你阅读有关 android 包如何工作的文档,因为你似乎不明白。
You have to put the images in the
res/drawable
folder. Then, you can access them by using:R.drawable.name_of_image
(forname_of_image.png
orname_of_image.jpg
).If you want to access them by their original name, you better save them in the
assets
folder. Then, you can access them by using theAssetManager
:If you want to save a programatically created image, you can do:
You can't save it to your project directory. I recommend you to read the documentation about how android packages work, because it seems you don't understand.