1

ハマった。もっともらしい解決策を何時間も探していましたが、手がかりはありません。

これが私の作成コードです:

  public class EventData extends SQLiteOpenHelper {

  public static final String TABLE_COMMENTS = "EventData";          //Our Table Name(let say ) Event Data

  public static final String TABLE_EVENT_NAME="eventName";
  public static final String TABLE_DAY="day";
  public static final String TABLE_START="sTime";
  public static final String TABLE_END="eTime";
  public static final String TABLE_IMGID="imgId";   //Primary Key
  public static final String TABLE_SUBSCRIBE="subStatus";
  //ImgId,sTime,eTime is int type(rest all are of String type)
  public static final String TABLE_FILENAME="fileName";

  private static final String DATABASE_NAME = "EventDB.db";
  private static final int DATABASE_VERSION = 1;

  // Database creation sql statement
  public static final String DATABASE_CREATE = "create table "
      + TABLE_COMMENTS + "(" + TABLE_IMGID
      + " integer primary key , " + TABLE_EVENT_NAME
      + " text , " +    TABLE_DAY+
      " text ," +       TABLE_START+
      " float , " + TABLE_END+
      " float , " +     TABLE_SUBSCRIBE+
      " integer ," +    TABLE_FILENAME+
      " text );";


  public EventData(Context context) {
    super(context, DATABASE_NAME, null, DATABASE_VERSION);
  }

  @Override
  public void onCreate(SQLiteDatabase database) {
    database.execSQL(DATABASE_CREATE);
  }

  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    Log.w(EventData.class.getName(),
        "Upgrading database from version " + oldVersion + " to "
            + newVersion + ", which will destroy all old data");
    db.execSQL("DROP TABLE IF EXISTS " + TABLE_COMMENTS);
    onCreate(db);
  }   
} 

別のクラスの私の挿入コードは次のとおりです。

 public Comment createComment(int id,String eN,String d,int sT,int eT,String fN,Boolean sub) {
ContentValues values = new ContentValues();
 //  values.put(EventData.TABLE_EVENT_NAME, comment);
values.put(EventData.TABLE_IMGID, id);
values.put(EventData.TABLE_EVENT_NAME,eN);
values.put(EventData.TABLE_DAY, d);
values.put(EventData.TABLE_START, sT);
values.put(EventData.TABLE_END, eT);
int temp=0;
if(sub==true)temp=1;
values.put(EventData.TABLE_SUBSCRIBE,temp);
values.put(EventData.TABLE_FILENAME, fN);


long insertId = database.insert(EventData.TABLE_COMMENTS, null,
    values);

Log.d("DB", "value inserted succcessfully");

Cursor cursor = database.query(EventData.TABLE_COMMENTS,allColumns, EventData.TABLE_IMGID + " = " + insertId, null,null, null, null);
Log.d("Sucess", "good so far");  
cursor.moveToFirst();
Comment newComment = cursorToComment(cursor);
cursor.close();
return newComment;
}

ここにlogcatがあります

01-30 01:31:53.141: E/Database(8787): Error inserting fileName=execute eTime=13  
 imgId=125 sTime=12 eventName=Execute 1.2 day=1 subStatus=0
01-30 01:31:53.141: E/Database(8787): android.database.sqlite.SQLiteException: table  
EventData has no column named subStatus: , while compiling: INSERT INTO  
EventData(fileName, eTime, imgId, sTime, eventName, day, subStatus) VALUES(?, ?, ?, ?,     
?,?, ?);
4

1 に答える 1