解决方案 »
- 通过蓝牙发送数据如何才能得到16进制数据?
- ExpandableListview中的onItemClickLIstener无反应
- listview的item的背景随最外层layout背景改变,求解救
- 【图】【牛人回答的问题】输入框长按弹出上下文菜单怎么才能改成中文的
- android数据传输缓慢问题
- android开发,程序运行没有问题,但是按Home键在回到本程序就会报错
- 写一个飞机大战用什么游戏引擎比较好
- 如何启动另外一个程序的BroadcastRecevier?
- 关于使用Fragment遇到的问题
- webview加载网页出错
- 平板的一个功能实现
- 手机百事通这种折扣软件大概是怎么与服务器传递数据呢,还有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()