Reputation: 332
I have created my table using sqlite for my android project. It was working just fine before. Initially, I created 3 fields to make sure the connection will work and it did so I added all the other fields I will need but I was getting an error with the cursor. After reading similar problems here, i figured it will be an issue with the onUpgrade so i uninstalled the app and reinstalled but now it keeps crashing and I am getting a syntax error.
Here is my code
public void onCreate(SQLiteDatabase db){
db.execSQL("CREATE TABLE " + DATABASE_TABLE_SITE_INFO + " ("
+ ROW_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
+ SYSAID_ID + " TEXT, "
+ SITE_ID + " TEXT, "
+ LINK_ID + " TEXT, "
+ CUSTOMER_NAME + " TEXT, "
+ SITE_CONTACT + " TEXT, "
+ TASK_TYPE + " TEXT, "
+ ADDRESS + " TEXT, "
+ REGION + " TEXT, "
+ PHONE + " TEXT, "
+ FAX + " TEXT, "
+ MOBILE + " TEXT, "
+ EMAIL + " TEXT, "
+ LANDLORD_NAME + " TEXT, "
+ RENT_STATUS + " TEXT, "
+ LOCATION + " TEXT, "
+ ENGINEER_NAME + " TEXT, "
+ ENGINEER_SIGN + " BLOB, "
+ POWER_STATUS + " TEXT, "
+ VOLTAGE_MEASUREMENT + " TEXT, "
+ AIRCON + " TEXT, "
+ SERVER_ROOM_STATUS + " TEXT, "
+ LOCATION_IDU + " TEXT, "
+ EARTHING + " TEXT, "
+ DISTANCE_IDU + " TEXT, "
+ SECURITY_CABLES + " TEXT, "
+ DUCTS + " TEXT, "
+ UNIT_TYPE + " TEXT, "
+ INST_TYPE + " TEXT, "
+ HAVE_ISP + " TEXT, "
+ RADIO + " TEXT, "
+ ISP_TYPE + " TEXT, "
+ ISP_NAME + " TEXT, "
+ SNR_RX + " TEXT, "
+ BS + " TEXT, "
+ REMARKS + " TEXT);");
And this is the error code i am getting
01-14 10:22:28.429 24406-24406/com.example.sweetiean.stlfieldinstallation1 E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.sweetiean.stlfieldinstallation1, PID: 24406
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.sweetiean.stlfieldinstallation1/com.example.sweetiean.stlfieldinstallation1.MainActivity}: android.database.sqlite.SQLiteException: near "(": syntax error (code 1): , while compiling: CREATE TABLE site_info_table(_id INTEGER PRIMARY KEY AUTOINCREMENT, sysaid_id TEXT, site_id TEXT, link_id TEXT, customer_name TEXT, site_contact_name TEXT, task_type TEXT, address TEXT, region TEXT, phone TEXT, fax TEXT, mobile TEXT, email TEXT, landlord_name TEXT, rent_status TEXT, location TEXT, engineer_name TEXT, engineer_sign BLOB, power_status TEXT, voltage_measure TEXT, aircon TEXT, server_room_status TEXT, location_of_idu TEXT, earthing TEXT, distance_idu TEXT, security_of_cables TEXT, ducts TEXT, unit_to_be_installed TEXT, inst_type TEXT, isp TEXT, radio_type TEXT, isp_type TEXT, isp_name TEXT, snr(rx) TEXT, bs TEXT, remarks TEXT);
Upvotes: 1
Views: 96
Reputation: 152927
snr(rx)
is not a valid column name because of the parentheses. Rename it to e.g. snr_rx
.
Upvotes: 3