-1

我正在为我正在创建的应用程序创建一个数据库,但是每当我运行我的应用程序并尝试将一些信息输入到我的数据库中时,什么都没有发生,并且 LogCat 中会显示一条错误消息。完整的错误信息是:

“04-09 17:22:18.208: E/Database(484): 在 0x2d7a30 准备‘CREATE TABLE ApplianceDetails (_id INTEGER PRIMARY KEY, appliance_name TEXT NOT NULL, appliance_wattage TEXT NOT NULLenergy_rates TEXT NOT NULL);'。

它与此代码相关联:

public class Database {

public static final String KEY_ROWID = "_id";
public static final String KEY_NAME = "appliance_name";
public static final String KEY_WATTAGE = "appliance_wattage";
public static final String KEY_ENERGY = "energy_rates";

private static final String DATABASE_NAME = "TheApplianceKeeperdb";
private static final String DATABASE_TABLE = "ApplianceDetails";
private static final int DATABASE_VERSION = 1;

private DbHelper ourHelper;
private final Context ourContext;
private SQLiteDatabase ourDatabase;

private static class DbHelper extends SQLiteOpenHelper{

    public DbHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
        // TODO Auto-generated constructor stub
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        // TODO Auto-generated method stub
        db.execSQL("CREATE TABLE " + DATABASE_TABLE + " (" +
                KEY_ROWID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
                KEY_NAME + " TEXT NOT NULL, " +
                KEY_WATTAGE + " TEXT NOT NULL" +
                KEY_ENERGY + " TEXT NOT NULL);"                                 
        );      
    }

任何有关如何解决此错误的帮助将不胜感激

4

1 回答 1

1

添加逗号和空格改变

KEY_WATTAGE + " TEXT NOT NULL" +KEY_WATTAGE + " TEXT NOT NULL, " +

于 2012-04-09T18:00:57.573 回答