android.database.sqlite.SQLiteException: near ")": syntax error (code 1) -
i check every thing many times still got message
android.database.sqlite.sqliteexception: near ")": syntax error (code 1): , while compiling: create table location (_id integer primary key autoincrement, location_setting text unique not null, city_name text not null, coord_lat real not null, coord_long real not null, );
final string sql_create_weather_table = "create table " + weathercontract.weatherentry.table_name + " (" + weathercontract.weatherentry._id + " integer primary key autoincrement," + // id of location entry associated weather data weathercontract.weatherentry.column_loc_key + " integer not null, " + weathercontract.weatherentry.column_date + " integer not null, " + weathercontract.weatherentry.column_short_desc + " text not null, " + weathercontract.weatherentry.column_weather_id + " integer not null," + weathercontract.weatherentry.column_min_temp + " real not null, " + weathercontract.weatherentry.column_max_temp + " real not null, " + weathercontract.weatherentry.column_humidity + " real not null, " + weathercontract.weatherentry.column_pressure + " real not null, " + weathercontract.weatherentry.column_wind_speed + " real not null, " + weathercontract.weatherentry.column_degrees + " real not null, " + // set location column foreign key location table. " foreign key (" + weathercontract.weatherentry.column_loc_key + ") references " + weathercontract.locationentry.table_name + " (" + weathercontract.locationentry._id + "), " + // assure application have 1 weather entry per day // per location, it's created unique constraint replace strategy " unique (" + weathercontract.weatherentry.column_date + ", " + weathercontract.weatherentry.column_loc_key + ") on conflict replace );"; final string sql_create_location_table = "create table "+ weathercontract.locationentry.table_name +" (" + weathercontract.locationentry._id + " integer primary key autoincrement, "+ weathercontract.locationentry.column_location_setting +" text unique not null, "+ weathercontract.locationentry.column_city_name + " text not null, "+ weathercontract.locationentry.column_coord_lat + " real not null, "+ weathercontract.locationentry.column_coord_long+ " real not null, "+" );"; sqlitedatabase.execsql(sql_create_location_table); sqlitedatabase.execsql(sql_create_weather_table);
its typo, check last line
weathercontract.locationentry.column_coord_long+ " real not null, "+" );";
remove ,
end after not null
, should like
weathercontract.locationentry.column_coord_long+ " real not null "+" );";
Comments
Post a Comment