2012-08-29 61 views
0

如何创建只有一行存储用户名和密码值的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); 
} 
+0

您应该将证书存储在Keychain中,而不是sqlite数据库中。请参阅:http://developer.android.com/reference/android/security/KeyChain.html – AW101

回答

0
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

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