本文介绍了在对于SQLite数据库Android的存储图像路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我开发打算将数据存储在SQLite数据库的应用程序。这是怎样的一个虚拟城市指南。结果
如此,我存储在DB中的一些文本元素,我想以存储存储在不同的列和DB的表装置的图像的路径和一个视频
I'm developing an application that intends to store the data in a SQLIte database. It's kind of a virtual city guide.
As so, I'm storing some text elements on the DB and I'd like to store the path of an image and a video stored in the device in different columns and tables of the DB.
种类:
_ID INTEGER PRIMARY KEY AUTOINCREMENT (id of the image)
IMAGE_PATH TEXT UNIQUE (path of the image associated with the ID)
谁能给我如何能做到这一点的例子吗?
Can anyone give some examples on how can I do this?
推荐答案
比尔加里的答案很适合一个图像,但我想这样做我用下面的code画廊:
The answer of Bill Gary works well for one image, but as I want to do a gallery I used the code below :
this.imgPath = new String[mImageCursor.getCount()];
int i = 0;
while (mImageCursor.moveToNext()) {
imgName = mImageCursor.getString(mImageCursor.getColumnIndex(MyDbAdapter.IMAGE_PATH));
Log.w(TAG, baseDir + imgName);
this.imgPath[i] = baseDir + imgName;
Log.w(TAG, baseDir + mImageCursor.getString(mImageCursor.getColumnIndex(MyDbAdapter.IMAGE_PATH)) + " After");
i++;
}
Gallery gallery = (Gallery) findViewById(R.id.VGgallery);
gallery.setAdapter(new MyImageAdapter(this, this.imgPath));
希望它可以帮助别人。
Hope it helps someone else.
这篇关于在对于SQLite数据库Android的存储图像路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!