-7
public class Database extends SQLiteOpenHelper {
public static final String DATABASE_NAME = "userdetail1";
public static final String TABLE_NAME = "sample";
public static final String COLUMN_ID = "id";
public static final String NAME = "username";
public static final String PASSWORD = "u_password";
public static final String table_create = "create table " + TABLE_NAME + "(" + COLUMN_ID + " INTEGER PRIMARY KEY," + NAME + "TEXT," + PASSWORD + "TEXT" + ")";
SQLiteDatabase database;
public Database(Context context, Object o, Object o1, int i) {
super(context, DATABASE_NAME, null, 1);
}
@Override
public void onCreate(SQLiteDatabase database) {
database.execSQL(table_create);
}
@Override
public void onUpgrade(SQLiteDatabase database, int i, int i1) {
database.execSQL("DROP TABLE IF EXISTS contacts");
onCreate(database);
}
public static int flag=0;
public void add(GetterandSetter gs)
{
database=this.getWritableDatabase();
ContentValues values=new ContentValues();
values.put(NAME,gs.getUsername());
values.put(PASSWORD,gs.getPassword());
database.insert(TABLE_NAME,null,values);
flag=1;
database.close();
}
}
我得到了錯誤,指出android.database.sqlite.SQLiteException:table示例有沒有指定列名(碼1):在編譯:(?,?)INSERT INTO樣品(用戶名,u_password)VALUES我想在android工作室做登錄模塊,但我得到的錯誤如下..(列名不存在)
我已經嘗試清理appdata,重新安裝應用程序,更改數據庫名稱 –
錯誤消息是否不會告訴您所有信息? – f1sh