新加了一个iIMAGE以后数据库报错,只有图中这么一行错
下面是我数据库的代码
package com.mlchelper.db;
import java.sql.Blob;
import com.mlchelper.dom.Infor_table;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.widget.EditText;
public class DBInfor {
private static final String DB_NAME = "person.db";
private static final String PERSON_TABLE = "peopleinfo";
private static final int DB_VERSION = 1;
public static final String in_ID = "_id";
public static final String iPHONE="pnumber";
public static final String iNAME="username";
public static final String iPASSWORD="password";
public static final String iHOBBY="hobby";
public static final String iBIRTH="birth";
public static final String iIMAGE="touxiang";
private SQLiteDatabase db;
private final Context context;
private DBOpenHelper dbOpenHelper;
public DBInfor(Context _context) {
context = _context;
}
/** Close the database */
public void close() {
if (db != null){
db.close();
db = null;
}
}
/** Open the database */
public void open() throws SQLiteException {
dbOpenHelper = new DBOpenHelper(context, DB_NAME, null, DB_VERSION);
try {
db = dbOpenHelper.getWritableDatabase();
}
catch (SQLiteException ex) {
db = dbOpenHelper.getReadableDatabase();
}
}
/*
- 数据添加功能,及插入数据 */ public long insert( Infor_table person){ ContentValues newvalues=new ContentValues(); newvalues.put(iPHONE,person.phonenumber); newvalues.put(iNAME,person.username); newvalues.put(iBIRTH, person.birth); newvalues.put(iHOBBY, person.hobby); newvalues.put(iPASSWORD, person.password); newvalues.put(iIMAGE, person.image); return db.insert(PERSON_TABLE, null, newvalues); }
/*
-
查询全部表格信息
*/
public Infor_table[] queryAllData(){
Cursor results=db.query(PERSON_TABLE, new String[]{in_ID,iPHONE,iNAME,iBIRTH,iHOBBY,iPASSWORD,iIMAGE}, null,null,null, null, iNAME);return ConvertToPeople(results);
}
/*
- 查询数据转换 */
public Infor_table[] ConvertToPeople(Cursor cursor){
int resultCounts=cursor.getCount();
if(resultCounts==0||!cursor.moveToFirst()){
return null;
}
Infor_table[] person=new Infor_table[resultCounts];
for (int i = 0; i < resultCounts; i++) {
person[i]=new Infor_table();
person[i].ID = cursor.getInt(cursor.getColumnIndex(iNAME));
person[i].phonenumber=cursor.getInt(cursor.getColumnIndex(iPHONE));
person[i].username=cursor.getString(cursor.getColumnIndex(iNAME));
person[i].birth=cursor.getString(cursor.getColumnIndex(iBIRTH));
person[i].hobby=cursor.getString(cursor.getColumnIndex(iHOBBY));
person[i].password=cursor.getString(cursor.getColumnIndex(iPASSWORD));
person[i].image=cursor.getString(cursor.getColumnIndex(iIMAGE));
cursor.moveToNext();
}
return person;
}
/*
- 更新个人信息 */ public long updateOnteData(String id ,Infor_table person){ String where = "username=?"; String[] whereArgs = new String[] {String.valueOf(id)}; ContentValues updatevalues=new ContentValues(); updatevalues.put(iNAME,person.username); updatevalues.put(iPHONE,person.phonenumber); updatevalues.put(iBIRTH,person.birth); updatevalues.put(iHOBBY, person.hobby); updatevalues.put(iPASSWORD, person.password); updatevalues.put(iIMAGE, person.image); return db.update(PERSON_TABLE, updatevalues, where , whereArgs);
}
/*
-
public void updatePoint(int idPoint,
int ColumnNr, int Column, int lamp, int armor, int lampState){
String where = "id=?";
String[] whereArgs = new String[] {String.valueOf(idPoint)};
ContentValues values = new ContentValues();
values.put(PointsDB.COLUMNNR, ColumnNr);
values.put(PointsDB.COLUNA, Column);
values.put(PointsDB.LAMP, lamp);
values.put(PointsDB.ARMOR, armor);
values.put(PointsDB.LAMPSTATE, lampState);
database.update(PointsDB.TABLE_NAME, values, where, whereArgs);
}
*//** 静态Helper类,用于建立、更新和打开数据库*/
private static class DBOpenHelper extends SQLiteOpenHelper {
public DBOpenHelper(Context context, String name, CursorFactory factory, int version) { super(context, name, factory, version); } private static final String PERSON_CREATE = "create table " + PERSON_TABLE + " (" + in_ID + " integer primary key autoincrement, "+ iPHONE + " integer, " + iNAME+" text not null, " + iBIRTH+" text,"+iHOBBY +" text, "+ iIMAGE + " text, " + iPASSWORD+" text not null);"; @Override public void onCreate(SQLiteDatabase _db) { _db.execSQL(PERSON_CREATE); _db.execSQL("insert into peopleinfo (_id,username,password,birth,hobby,pnumber,touxiang) values (1,'admin','password','1995-1-30','reading','676552',null)"); } @Override public void onUpgrade(SQLiteDatabase _db, int _oldVersion, int _newVersion) { _db.execSQL("DROP TABLE IF EXISTS " + PERSON_TABLE); onCreate(_db); } }
}