与错列数创建数据库 [英] creates db with wrong number columns

查看:161
本文介绍了与错列数创建数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建一个表4列(包括_id),并不管我做不断,只有3列(包括_id)创建一个表。

I'm trying to create a table with 4 columns (including _id) and no matter what I do it keeps on creating a table with only 3 columns (including _id).

我的表定义如下:

private static final String DATABASE_CREATE =
        "create table collections (_id integer primary key autoincrement, "
        + "name text not null, description text not null, image integer not null);";

和我的onCreate:

And my onCreate:

@Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(DATABASE_CREATE);
    }

如何我访问数据:

How i'm accessing the data:

public View getView(int position, View convertView, ViewGroup parent) {

        cursor.moveToPosition(position);

        LinearLayout ll = new LinearLayout(mContext); 
        ll.setOrientation(LinearLayout.VERTICAL);

        ImageView i = new ImageView(mContext);


        i.setImageResource(cursor.getInt(3));  //access to the image column
        i.setScaleType(ImageView.ScaleType.FIT_XY);
        i.setLayoutParams(new Gallery.LayoutParams(150, 150));

        // The preferred Gallery item background
        i.setBackgroundResource(mGalleryItemBackground);


        ll.addView(i); 

        TextView tv = new TextView(ll.getContext());

        tv.setTag(mText[position]);
        tv.setText(cursor.getString(1)); //access to the name column
        tv.setLayoutParams(new Gallery.LayoutParams(48, 48));
        ll.addView(tv); 

        return ll;
    }

不管是什么我尝试,它使离开塔形象出表...谢谢我会AP preciate任何帮助,我得到:)

No matter what I try, it keeps leaving the column image out of the table… Thanks I'll appreciate any help I get :)

推荐答案

这是一个非常愚蠢的事情,我浪费任何人的时间真的很抱歉。我真的AP preciate大家的帮助。

It was a really dumb thing and I'm really sorry for wasting anyone's time. I really appreciate everyone's help.

我是不是正确获取数据。所以今后如果有人重复我的错误首先检查你的获取方法。

I wasn't fetching the data correctly. So in the future if anyone repeats my mistake check your fetch methods first.

这篇关于与错列数创建数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆