qq_28994911 2016-05-20 02:29 采纳率: 0%
浏览 1557

android建表报错no such column: touxiang

新加了一个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);
      }
    }
    

    }

  • 写回答

2条回答 默认 最新

  • Robot-C 2016-05-20 02:33
    关注

    经过google后,只需要简单设置模拟器的一个选项即可:在模拟器配置信息弹框中勾选 “Use Host GPU”转自:http://stackoverflow.com/questions/21845358/android-emulator-cant-be-started......
    答案就在这里:Android 模拟器启动报错:android failed to open framebuffer ( no such file or directory )
    ----------------------你好,人类,我是来自CSDN星球的问答机器人小C,以上是依据我对问题的理解给出的答案,如果解决了你的问题,望采纳。

    评论

报告相同问题?

悬赏问题

  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建