データベースにクエリを実行すると、エラーが発生し続けSQLException: no such column
、クエリが問題なく表示される理由がわかりません
Cursor nameCursor = context.getContentResolver().query(StatusList.STATUS_URI,new String[] {StatusList.STATUS_NAME,StatusList.STATUS_PERMISSIONS,StatusList.STATUS_ECM2ID}
,StatusList.STATUS_TYPE+"=1"+" AND "+StatusList.STATUS_NAME+"="+incidentCursor.getString(0),null,null);
ここに完全なエラーがあります
08-01 15:39:59.104: W/System.err(8623): android.database.sqlite.SQLiteException: no such column: SIS (code 1): , while compiling: SELECT name, permissions, ecm2id FROM Status WHERE (type=1 AND name=SIS)
08-01 15:39:59.112: W/System.err(8623): at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
08-01 15:39:59.112: W/System.err(8623): at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:882)
08-01 15:39:59.120: W/System.err(8623): at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:493)
08-01 15:39:59.120: W/System.err(8623): at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
08-01 15:39:59.120: W/System.err(8623): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
08-01 15:39:59.120: W/System.err(8623): at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
08-01 15:39:59.120: W/System.err(8623): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
08-01 15:39:59.120: W/System.err(8623): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1314)
08-01 15:39:59.128: W/System.err(8623): at android.database.sqlite.SQLiteQueryBuilder.query(SQLiteQueryBuilder.java:400)
08-01 15:39:59.128: W/System.err(8623): at android.database.sqlite.SQLiteQueryBuilder.query(SQLiteQueryBuilder.java:294)
08-01 15:39:59.128: W/System.err(8623): at ecm2.android.Providers.StatusList.query(StatusList.java:132)
08-01 15:39:59.128: W/System.err(8623): at android.content.ContentProvider.query(ContentProvider.java:652)
08-01 15:39:59.128: W/System.err(8623): at android.content.ContentProvider$Transport.query(ContentProvider.java:189)
08-01 15:39:59.128: W/System.err(8623): at android.content.ContentResolver.query(ContentResolver.java:370)
08-01 15:39:59.135: W/System.err(8623): at android.content.ContentResolver.query(ContentResolver.java:313)
08-01 15:39:59.135: W/System.err(8623): at ecm2.android.MainActivity.createNewDialog(MainActivity.java:1167)
08-01 15:39:59.135: W/System.err(8623): at ecm2.android.MainActivity$ListViews.onListItemClick(MainActivity.java:641)
08-01 15:39:59.135: W/System.err(8623): at android.support.v4.app.ListFragment$2.onItemClick(ListFragment.java:58)
08-01 15:39:59.135: W/System.err(8623): at android.widget.AdapterView.performItemClick(AdapterView.java:298)
08-01 15:39:59.135: W/System.err(8623): at android.widget.AbsListView.performItemClick(AbsListView.java:1086)
08-01 15:39:59.143: W/System.err(8623): at android.widget.AbsListView$PerformClick.run(AbsListView.java:2855)
08-01 15:39:59.143: W/System.err(8623): at android.widget.AbsListView$1.run(AbsListView.java:3529)
08-01 15:39:59.143: W/System.err(8623): at android.os.Handler.handleCallback(Handler.java:615)
08-01 15:39:59.143: W/System.err(8623): at android.os.Handler.dispatchMessage(Handler.java:92)
08-01 15:39:59.143: W/System.err(8623): at android.os.Looper.loop(Looper.java:137)
08-01 15:39:59.143: W/System.err(8623): at android.app.ActivityThread.main(ActivityThread.java:4745)
08-01 15:39:59.143: W/System.err(8623): at java.lang.reflect.Method.invokeNative(Native Method)
08-01 15:39:59.151: W/System.err(8623): at java.lang.reflect.Method.invoke(Method.java:511)
08-01 15:39:59.151: W/System.err(8623): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
08-01 15:39:59.151: W/System.err(8623): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-01 15:39:59.151: W/System.err(8623): at dalvik.system.NativeStart.main(Native Method)
基本的に私がやろうとしていることは、データベースにクエリを実行してtype 1
、name
そのようなレコードが存在するという事実を知っているので、なぜこのエラーが発生するのかわかりません
編集: データベース作成コード
private static class DatabaseHelper extends SQLiteOpenHelper
{
DatabaseHelper(Context context)
{
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db)
{
createTables(db);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion,
int newVersion)
{
Log.w("Messages", "Upgrading database from version " + oldVersion
+ " to "
+ newVersion + ", which will destroy all old data");
db.execSQL("DROP TABLE IF EXISTS Incidents");
db.execSQL("DROP TABLE IF EXISTS Distributions");
onCreate(db);
}
private void createTables(SQLiteDatabase db){
db.execSQL("CREATE TABLE " + INCIDENTS_TABLE + "(" + INCIDENT_ID + " integer primary key autoincrement, " +
INCIDENT_ECM2ID + " INTEGER, " + INCIDENT_STATON_NAME + " TEXT, " + INCIDENT_READ + " INTEGER, " + INCIDENT_TOC + " TEXT, " +
INCIDENT_STATION_ID + " INTEGER, " + INCIDENT_MESSAGE_ID + " INTEGER, " + INCIDENT_MESSAGE + " TEXT);");
db.execSQL("CREATE TABLE " + DISTRIBUTION_MESSAGES_TABLE + "(" + DIST_ID + " integer primary key autoincrement, " +
DIST_MESSAGE_ID + " INTEGER, " + DIST_ECM2ID + " INTEGER, " + DIST_SENDER_EMAIL + " TEXT, " +
DIST_SENDER_NAME + " TEXT, " + DIST_STATION_ID + " INTEGER, " + DISC_READ + " INTEGER, " + DIST_TOC + " TEXT, "
+ DIST_SUBJECT +" TEXT, " + DIST_MESSAGE + " TEXT);");
}
}