如何在Sqlite中存储图像位置(从filepicker / Intent获取) [英] How to store Image location (fetching from filepicker/Intent) in Sqlite
问题描述
我是Android开发的新手。我试图在Sqlite数据库中存储图像文件位置。从任意文件管理器或库中收到Intent的图像。我想将其真实路径存储到数据库中,以便我可以在下次检索任何操作。我不想使用blob / dont想要在数据库中存储图像。我找不到更好的解决方案。请帮助。
I am new to Android Development. I am trying to store Image file location in Sqlite database. Image is received from Intent with any file manager or gallery. I want to store its real path into the database so i can retrieve it next time for any action. I don't want to use blob/dont want to store image in the database. I am not finding any better solutions. Please help.
推荐答案
您可以保存图像路径,并始终检查路径是否有效。
You can save the image path and always check if the path is valid or exists.
您可以使用意图来获取图像:
You can use an intent to pick up the image:
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType("image/*");
startActivityForResult(intent, PICK_IMAGE_REQUEST_CODE);
并获取图片路径:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == PICK_IMAGE_REQUEST_CODE) {
/** You have to call the getData or getDataString to get the images address */
Log.i("CCC", data.getDataString());
}
}
使用该路径可以将其保存在数据库中。
With the path you can save it in the database.
享受!!
这篇关于如何在Sqlite中存储图像位置(从filepicker / Intent获取)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!