1

这段代码是创建一个新表。

 import android.database.sqlite.SQLiteOpenHelper;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;


public class MySQLHelper extends SQLiteOpenHelper {

    public static final String DATABASE_NAME = "verlaufAufgaben.db";
    public static final int DATABASE_VERSION = 1;

创建表

    private static final String TABLE_CREATE_VERLAUF = ""
            +"create table VERLAUF ("
            +" ID integer primary key, "
            +" Zahl1 int,) ";


    public MySQLHelper(Context context) 
    {   
        super (context, DATABASE_NAME, null, DATABASE_VERSION);
    }

创建 SQLite 数据库

    @Override
    public void onCreate(SQLiteDatabase database)
    {
        database.execSQL(TABLE_CREATE_VERLAUF);
    }

升级数据库

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
    {
        Log.w(MySQLHelper.class.getName(),
                "Upgrading database from version " + oldVersion + "to "
                + newVersion + ", which all destroy all old data");
        db.execSQL("DROP TABLE IF EXISTS SCANITEM");
        onCreate(db);
    }

}

这段代码有什么问题,它因为表格而显示错误?

4

1 回答 1

3

您让表创建以逗号结尾的 DDL...删除它!

private static final String TABLE_CREATE_VERLAUF = ""
        +"create table VERLAUF ("
        +" ID integer primary key, "
        +" Zahl1 int) ";
于 2012-12-26T12:56:12.750 回答