對我而言,這是第一篇文章。我第一次涉足Android開發,只有有限的Java編程經驗。在我的問題...在Android中創建表格
當在dbHelper類中創建多個表時,哪種方法是首選?
初始化變量來保存創建的字符串...
private static final String DATABASE_CREATE =
"create table notes (_id integer primary key autoincrement, "+
"title text not null, body text not null);";
db.execSQL(DATABASE_CREATE);
或只是......
db.execSQL("create table notes (_id integer primary key autoincrement, "+
"title text not null, body text not null);"
);
我已經看到了這兩種方式,我試圖理解爲什麼越來越多的代碼會更好。
謝謝!
最好的方法訪問它們將存儲所有'終/ constants'在一個單獨的類。所以在將來'如果有什麼事情需要改變,那麼你可以在一個班級輕鬆改變。 –