在对于SQLite数据库Android的存储图像路径路径、图像、数据库、SQLite

由网友(沧桑的笑容)分享简介:我开发打算将数据存储在SQLite数据库的应用程序。这是怎样的一个虚拟城市指南。结果如此,我存储在DB中的一些文本元素,我想以存储存储在不同的列和DB的表装置的图像的路径和一个视频I'm developing an application that intends to store the data in a SQL...

我开发打算将数据存储在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.

阅读全文

相关推荐

最新文章