在这个类中,我将声明此表的表和列,但
public static abstract class Wish_list_Table implements BaseColumns {
public static final String TABLE_NAME = "WISH_LIST";
public static final String COL_NAME = "NAME";
public static final String COL_PHOTO = "PHOTO";
public static final String COL_DATE = "DATE";
public static final String COL_PRICE = "PRICE";
public static final String COL_LATITUDE = "LATITUDE";
public static final String COL_LONGITUDE = "LONGITUDE";
public static final String COL_LOCATION = "LOCATION";
public static final String COL_DESC = "DESC";
}
这是查询create table ...这是log cat content .....
java.lang.RuntimeException:无法获取提供者com.info.wishlist.WishListProvider:android.database.sqlite.SQLiteException:near“TABLEWISH_LIST”:语法错误(代码1):,同时编译:CREATE TABLEWISH_LIST(_idINTEGER PRIMARYKEY ,NAMETEXT,DESCTEXT,LOCATIONREAL ,LATITUDEREAL,LONGITUDEREAL,PRICEINTEGER,DATEINTEGER,PHOTOBLOB)
public static final String CREATE_DB = "CREATE TABLE"
+ Wish_list_Table.TABLE_NAME + "(" + Wish_list_Table._ID
+ "INTEGER PRIMARY KEY," + Wish_list_Table.COL_NAME + "TEXT,"
+ Wish_list_Table.COL_DESC + "TEXT," + Wish_list_Table.COL_LOCATION
+ "REAL," + Wish_list_Table.COL_LATITUDE + "REAL,"
+ Wish_list_Table.COL_LONGITUDE + "REAL,"
+ Wish_list_Table.COL_PRICE + "INTEGER," + Wish_list_Table.COL_DATE
+ "INTEGER," + Wish_list_Table.COL_PHOTO + "BLOB)";
答案 0 :(得分:2)
您需要在列名称和类型
之间添加空格public static final String CREATE_DB = "CREATE TABLE "// note the space
+ Wish_list_Table.TABLE_NAME + "(" + Wish_list_Table._ID
+ " INTEGER PRIMARY KEY," + Wish_list_Table.COL_NAME + " TEXT,"
+ Wish_list_Table.COL_DESC + " TEXT," + Wish_list_Table.COL_LOCATION
+ " REAL," + Wish_list_Table.COL_LATITUDE + " REAL,"
+ Wish_list_Table.COL_LONGITUDE + " REAL,"
+ Wish_list_Table.COL_PRICE + " INTEGER," + Wish_list_Table.COL_DATE
+ " INTEGER," + Wish_list_Table.COL_PHOTO + " BLOB)";
答案 1 :(得分:0)
我得到了解决方案......每个字段的开始和结束都需要空间。
public static final String CREATE_DB = " CREATE TABLE "
+ Wish_list_Table.TABLE_NAME + "(" + Wish_list_Table._ID
+ " INTEGER PRIMARY KEY, " + Wish_list_Table.COL_NAME + " TEXT, "
+ Wish_list_Table.COL_DESC + " TEXT, " + Wish_list_Table.COL_LOCATION
+ " REAL, " + Wish_list_Table.COL_LATITUDE + " REAL, "
+ Wish_list_Table.COL_LONGITUDE + " REAL, "
+ Wish_list_Table.COL_PRICE + " INTEGER, " + Wish_list_Table.COL_DATE
+ " INTEGER, " + Wish_list_Table.COL_PHOTO + " BLOB)";