解决方案 »
- DatePicker问题,求指点
- android http 代理
- adb遭遇重名设备,-s怎么分辨呢?
- AutoCompleteTextView怎么修改提示框颜色
- 求助,textView组件属性autoLink设置了为web,但是如这种情况显示不了成链接形式"你好www.baidu.com你好"
- android怎样动态生成布局文件,指定控件显示位置
- Intent.DATA_CONNECTION_CHANGED_ACTION 这么用是否有问题啊?请高手指点下。
- 通过USB 传输数据,请大侠赐教!谢谢!
- 关于android的res中的文件删除问题, 删除了还是存在是怎么回事,
- 求教Android如何实现动态表格显示
- 平板的一个功能实现
- 手机百事通这种折扣软件大概是怎么与服务器传递数据呢,还有ui的设计。
改成这样:
PetTrackerDatabaseHelper mDatabase=new PetTrackerDatabaseHelper(this);
此方法API中是这么解释的
public abstract Context getApplicationContext ()
Since: API Level 1 Return the context of the single, global Application object of the current process. This generally should only be used if you need a Context whose lifecycle is separate from the current context, that is tied to the lifetime of the process rather than the current component.
把原来的db文件删除了
PetTrackerDatabaseHelper的oncreate改成下面的 @Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("create table pets (_id integer primary key autoincrement ,pet_name text,pet_type_id integer);");
db.execSQL("insert into pets values(5,\"item1\",1);");
db.execSQL("insert into pets values(6,\"item2\",2);");
db.execSQL("insert into pets values(7,\"item3\",3);");
db.execSQL("insert into pets values(8,\"item4\",4);");
db.execSQL("insert into pets values(9,\"item5\",5);");
}
貌似这样也行this.getApplicationContext()