大佬教程收集整理的这篇文章主要介绍了我想将我的图像存储在 Android Studio 的 SQLite 数据库中,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
所以我在网上看到了很多资源,通常是关于使用 blob 类型将我的图像存储在 androID studio 的 SQLite 数据库表中,但我实际上尝试过,但不知道该怎么做。
我实际上遇到了获取图像路径并存储为资源 ID 然后在我的主要活动中调用它的概念
这是我在检索方面所看到的(我正在开发一个测验应用程序,我需要检索数据库中存储的图像并像我的问题一样显示为 ImageVIEw。)
有什么办法可以让我知道如何将图像存储在 androID studio 的 sqlite 表中,然后这样检索它。我知道 getimage()
是将被声明的 getter,资源将存储在其中可能是 sqlite put 命令,该命令通常用于使用内容值插入值
photoQuestion = (ImageVIEw) findVIEwByID(R.ID.photoquestion);
photoQuestion.setimageresource(PHOTO_QUESTION.getimage());
我的代码插入数据到表中,到目前为止我的问题(应该是图像)我一直在测试它作为字符串能够显示并查看它是否工作,但现在我想替换表的第一个字段到图像(从当前字符串改为图像数据类型)
private voID fillQuestions() {
PeopleModeQuestions question1 = new PeopleModeQuestions("photo of john","Father","Mother",1);
addQuestions(question1); // question will be inserted in database everytime this method is called
PeopleModeQuestions question2 = new PeopleModeQuestions("photo of Mary",2);
addQuestions(question2);
PeopleModeQuestions question3 = new PeopleModeQuestions("photo of susan","Sister","FrIEnd",1);
addQuestions(question3);
PeopleModeQuestions question4 = new PeopleModeQuestions("photo of mark",2);
addQuestions(question4);
}
private voID addQuestions(PeopleModeQuestions questions) {
ContentValues values = new ContentValues();
// using the getter method,get questions out of the object
values.put(PeopleModeConstants.MemoryDementiaQuestions.MemoryDementia_relatives_column_Photo,questions.getPhoto());
values.put(PeopleModeConstants.MemoryDementiaQuestions.MemoryDementia_relatives_column_Relationship1,questions.getRelationship1());
values.put(PeopleModeConstants.MemoryDementiaQuestions.MemoryDementia_relatives_column_Relationship2,questions.getRelationship2());
values.put(PeopleModeConstants.MemoryDementiaQuestions.MemoryDementia_relatives_column_CorrectRelationship,questions.getCorrectRelationship());
db.insert(PeopleModeConstants.MemoryDementiaQuestions.MemoryDementia_relatives_table,null,values);
}
您能否将图像存储在 Drawable 文件夹中?我有一个特别的应用程序,它有大约 50 张图像,并且运行良好。我知道它会变得有点笨拙,但这会是我的第一个想法吗?或者您是否有数百张图片需要提取?
以编程方式设置图像视图:
@H_550_2@myImage.setImageresource(getresources().getIdentifier("myImage3.png","drawable",getPackagename()));以上是大佬教程为你收集整理的我想将我的图像存储在 Android Studio 的 SQLite 数据库中全部内容,希望文章能够帮你解决我想将我的图像存储在 Android Studio 的 SQLite 数据库中所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。