【问题标题】:DB for credentials凭证数据库
【发布时间】:2012-08-29 20:57:25
【问题描述】:

如何创建一个只有一行来存储用户名和密码值的 sqlite 数据库。任何时候尝试添加其他数据,应用程序都不允许。

   public void onCreate(SQLiteDatabase db) {
    // TODO Auto-generated method stub      

    String sqlDataStore = "create table if not exists " +
    DATABASE_NAME + " ("+ BaseColumns._ID + " integer primary key autoincrement,"

                + COLUMN_USER + " text not null,"
                + COLUMN_CODE + " text not null);";

    db.execSQL(sqlDataStore);
}

【问题讨论】:

标签: database cursor android-sqlite


【解决方案1】:
String sqlDataStore = "create table if not exists " +
TABLE_NAME + " ("+ BaseColumns._ID + " integer primary key autoincrement,"

            + COLUMN_USER + " text not null,"
            + COLUMN_CODE + " text not null);";

TABLE_NAME 不是DATABASE_NAME

如果您想要更好的答案,请提交您编写的代码以添加新数据。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-06-15
    • 2016-12-21
    • 1970-01-01
    • 2014-03-21
    • 2017-11-26
    • 2019-04-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多