闪退 求解???
package com.y.cx_sql;
import android.os.Bundle;
import android.util.Log;
import android.app.Activity;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SqliteOpebHelper helper=new SqliteOpebHelper(MainActivity.this,"person");
SQLiteDatabase db=helper.getWritableDatabase();//数据库访问对象
ContentValues values =new ContentValues();
values.put("name", "张三");
values.put("age", "25岁");
values.put("sex", "男");
db.insert("person",null, values);
values.clear();
values.put("name", "李四");
values.put("age", "25岁");
values.put("sex", "男");
db.insert("person",null, values);
values.clear();
values.put("name", "王舞");
values.put("age", "15岁");
values.put("sex", "女");
db.insert("person",null, values);
values.clear();
values.put("name", "张三丰");
values.put("age", "28岁");
values.put("sex", "女");
db.insert("person",null, values);
values.clear();
values.put("name", "张三疯");
values.put("age", "88岁");
values.put("sex", "女");
db.insert("person",null, values);
values.clear();
values.put("sex", "男");
db.update("person", values, "_id=?", new String[]{"4"});
db.delete("person", "name=?", new String[]{"张三疯"});
Cursor cursor=db.rawQuery("select*from person",null);
if(cursor!=null){
String []columns=cursor.getColumnNames();
while(cursor.moveToNext()){
for(String ColumnName:columns){
Log.i("info", cursor.getString(cursor.getColumnIndex(ColumnName)));
}
}
cursor.close();
}
db.close();
}
}