关于创建数据库的sqlite日志

时间:2013-10-28 00:49:47

标签: android sqlite

这是我创建数据库的代码,但它不起作用,我不知道为什么。

public class DBAdapter {

    private static final String DATABASE_NAME = "Enquete15";
    private static final int DATABASE_VERSION = 3;

    private static final String MENAGE = "table_MENAGE";

    private static final String _id = "Numero_du_Questionnaire";
    private static final String col_Code_district = "Code_district";
    private static final String col_Region= "region";
    private static final String col_Provence_prefecture  = "provence_prefecture";
    private static final String col_Commune_Arrondissement  = "Commune_Arrondissement ";
    private static final String col_N_district  = "Numero_district ";
    private static final String col_N_M_district = "N_ménage_district ";
    private static final String col_N_menage_logement  = "N_menage_logement ";
    private static final String col_Adresse_menage = "Adresse_menage";
    private static final String col_Nom_Enqueteur = "Nom_enqueteur";
    private static final String col_code_enquêteur  = "code_enqueteur ";
    private static final String col_Date_realisation_enquête  = "Date_réalisation_enquête ";
    private static final String col_Nom_controleur  = "Nom_contrôleur ";
    private static final String col_code_controleur  = "code_contrôleur ";
    private static final String col_Date_controle  = "Date_contrôle ";
    private static final String col_echantillon_principal  = "echantillon_principal";
    private static final String col_Statut_enquêté  = "Statut_enquêté ";
    private static final String col_Observations   = "Observations ";
    private static final String col_Type_habitat   = "Type_habitat";
    private static final String col_Statut_occupation   = "Statut_occupation ";
    private static final String col_Nombre_ménages_habitant_logement   = "Nombre_ménages_habitant_logement ";
    private static final String col_Nombre_pièces_occupes_ménage   = "Nombre_pièces_occupés_ménage ";
    private static final String col_Mode_principal_approvisionnement_eau_potable    = "Mode_principal_approvisionnement_eau_potable  ";
    private static final String col_Mode_principal_éclairage    = "Mode_principal_éclairage ";
    private static final String col_Mode_principal_assainissement   = "Mode_principal_assainissement  ";
    private static final String col_Disposition_local_cuisine   = "Disposition_local_cuisine ";
    private static final String col_Disposition_local_WC = "Disposition_local_WC ";
    private static final String col_Disposition_salle_eau = "Disposition_salle_eau(douche_baignoire)  ";

    private static final String DATABASE_CREATE = "CREATE TABLE " + MENAGE + "(" + _id +" INTEGER PRIMARY KEY AUTOINCREMENT,"
                + col_Region +" TEXT,"+  col_Provence_prefecture +" TEXT,"
    + col_Commune_Arrondissement +" TEXT,"+ col_N_district +" INT,"
    + col_N_M_district +" INT,"+ col_N_menage_logement +" INT,"+ col_Adresse_menage + " INT," 
    + col_Nom_Enqueteur +" INT,"+ col_code_enquêteur +" INT,"+ col_Date_realisation_enquête +" INT,"+ col_Nom_controleur +" INT,"+ col_code_controleur +" INT,"+ col_Date_controle +" INT,"+ col_echantillon_principal +" INT,"+ col_Statut_enquêté +" INT,"+ col_Observations +" INT,"+ col_Type_habitat +" INT,"+ col_Statut_occupation +" INT,"+ col_Nombre_ménages_habitant_logement +" INT,"
    + col_Nombre_pièces_occupes_ménage +" INT,"+ col_Mode_principal_approvisionnement_eau_potable +" INT,"
    + col_Mode_principal_éclairage +" INT,"+ col_Mode_principal_assainissement +" INT,"
    + col_Disposition_local_cuisine +" INT,"+ col_Disposition_local_WC +" INT,"
    + col_Disposition_salle_eau + " INT,"+ col_Disposition_local_WC +" INT" + ")";

LogCat在“(”。

附近显示语法错误

1 个答案:

答案 0 :(得分:0)

似乎错误是由您的某个列中的括号引起的:

private static final String col_Disposition_salle_eau = "Disposition_salle_eau(douche_baignoire)  ";

删除并避免使用表名和列名的括号。

此外,还有一个重复的列名:

+ col_Disposition_local_WC +" INT,"
+ col_Disposition_salle_eau + " INT,"
+ col_Disposition_local_WC +" INT" + ")"; // duplicate 

删除其中一个。