【发布时间】:2012-12-05 17:21:37
【问题描述】:
我的第一篇文章。我是第一次涉足 Android 开发,Java 编程经验有限。关于我的问题...
在 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);"
);
我已经看到了这两种方式,我试图理解为什么更多的代码会比更少的代码更好。
谢谢!
【问题讨论】:
-
最好的方法是将所有
final/constants存储在一个单独的类中。所以在future如果有什么需要改变的,那么你可以很容易地在一堂课中改变。
标签: android coding-style create-table