2012-08-29 59 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

如果您想要更好的答案,請提交您編寫的代碼以添加新數據。