私はこれについてぐるぐる回ってきました。列の選択を null に設定すると、すべて正常に動作します。列を選択しようとすると、「投影で不明な列」という致命的なエラーが発生します。列名が正しいことを確認しました。
列選択コードは次のとおりです。
String[] MyColumns = new String[] { MyTable.COLUMN_ID, MyTable.COLUMN_A,
MyTable.COLUMN_B, MyTable.COLUMN_C };
Uri Myuri = MyContentProvider.CONTENT_URI; //specify the content provider location (Uri)
Cursor Mycursor = getContentResolver().query(Myuri, MyColumns, null, null, null);
また、MyColumns 変数の代わりに新しい文字列をクエリに入れてみました。それも失敗します。ヘルプ!助言がありますか?
@Yul、@Praful Bhatnagar: 要求されたテーブル作成コードは次のとおりです (注: これは contentprovider データベースです)。
public class MyTable {
// Define Database table and column names
public static final String TABLE_NAME = "MyTable";
public static final String COLUMN_ID = "_id";
public static final String COLUMN_A = "test1";
public static final String COLUMN_B = "test2";
public static final String COLUMN_C = "test3";
// データベース作成 sql ステートメント
private static final String DATABASE_CREATE = "create table " +TABLE_NAME+ "(" +
COLUMN_ID + " integer primary key autoincrement, " +
COLUMN_A + " text not null," +
COLUMN_B + " long not null," +
COLUMN_C + " real);";
public static void onCreate(SQLiteDatabase database) {
database.execSQL(DATABASE_CREATE);
}