当前位置: 首页 > 知识库问答 >
问题:

"null"附近的SQLiteExcture:语法错误

卫飞鹏
2023-03-14

首先,有类似的问题,比如1,2,3,4,5,但没有提到解决这个问题的答案。

LogCat错误

09-02 05:27:31.213: E/SQLiteDatabase(8442):错误插入日=2个月=9值=3.0年=2015 09-02 05:27:31.213: E/SQLiteDatabase(8442):android.database.sqlite.SQLiteExc0019:近空:语法错误(代码1):,编译时:INSERT INTO null(日,月,值,年)值 (?,?,?,?)09-02 05:27:31.213: E/SQLiteDatabase(8442): atandroid.database.sqlite.SQLiteConnection.native准备语句(本地方法)09-02 05:27:31.213: E/SQLiteDatabase(8442): atandroid.database.sqlite.SQLiteConnection.acquire准备语句(SQLiteConnection.java:895)09-02 05:27:31.213: E/SQLiteDatabase(8442): atandroid.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:506)09-02 05:27:31.213: E/SQLiteDatabase(8442): atandroid.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)09-02 05:27:31.213: E/SQLiteDatabase(8442): atandroid.database.sqlite.SQLiteProgram.(SQLiteProgram.java:58)09-02 05:27:31.213: E/SQLiteDatabase(8442): atandroid.database.sqlite.SQLite语句。(SQLiteStatement.java:31)09-02 05:27:31.213: E/SQLiteDatabase(8442):在android.database.sqlite.SQLiteDatabase.insert与冲突(SQLiteDatabase.java:1469)09-02 05:27:31.213: E/SQLiteDatabase(8442):在android.database.sqlite.SQLite数据库。Main Activity-输入(Main Activity-java: 210)09-02 05:27:31.213: E/SQLiteDatabase(8442): at Developer. mohab. gymee. Cardio. InsertDialogue. onClark(InsertDialogue. java: 47)

数据库表中返回错误的代码段

final String RUNNING = "CREATE TABLE " + Contract.Cardio_chart.Values.Running.TABLE + " (" +
            Contract.Cardio_chart.Values._ID + " INTEGER PRIMARY KEY," +
            Contract.Cardio_chart.Values.DAY + " INTEGER NOT NULL, " +
            Contract.Cardio_chart.Values.MONTH + " INTEGER NOT NULL, " +
            Contract.Cardio_chart.Values.YEAR + " INTEGER NOT NULL, " +
            Contract.Cardio_chart.Values.VALUE + " REAL NOT NULL " +
            " );";

数据库类

public class Database extends SQLiteOpenHelper {
public static final String DATABASE_NAME = "gym";
public static final int DATABASE_VERSION = 31 ;
public Database(Context c){
    super(c,DATABASE_NAME,null,DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
    // GYM WEIGHTS TABLES
    final String SQUAT = "CREATE TABLE " + Contract.Squat.TABLE + " (" +
            Contract.Squat._ID + " INTEGER PRIMARY KEY," +
            Contract.Squat.DAY + " INTEGER NOT NULL, " +
            Contract.Squat.MONTH + " INTEGER NOT NULL, " +
            Contract.Squat.YEAR + " INTEGER NOT NULL, " +
            Contract.Squat.VALUE + " REAL NOT NULL " +
            " );";
    final String BENCH = "CREATE TABLE " + Contract.Bench.TABLE + " (" +
            Contract.Bench._ID + " INTEGER PRIMARY KEY," +
            Contract.Bench.DAY + " INTEGER NOT NULL, " +
            Contract.Bench.MONTH + " INTEGER  NOT NULL, " +
            Contract.Bench.YEAR + " INTEGER  NOT NULL, " +
            Contract.Bench.VALUE + " REAL NOT NULL " +
            " );";
    final String DEADLIFT = "CREATE TABLE " + Contract.Deadlift.TABLE + " (" +
            Contract.Deadlift._ID + " INTEGER PRIMARY KEY," +
            Contract.Deadlift.DAY + " INTEGER  NOT NULL, " +
            Contract.Deadlift.MONTH + " INTEGER  NOT NULL, " +
            Contract.Deadlift.YEAR + " INTEGER  NOT NULL, " +
            Contract.Deadlift.VALUE + " REAL NOT NULL " +
            " );";
    // BODY RATIO TABLES
    final String CHEST = "CREATE TABLE " + Contract.Chest.TABLE + " (" +
            Contract.Chest._ID + " INTEGER PRIMARY KEY," +
            Contract.Chest.DAY + " INTEGER  NOT NULL, " +
            Contract.Chest.MONTH + " INTEGER  NOT NULL, " +
            Contract.Chest.YEAR + " INTEGER  NOT NULL, " +
            Contract.Chest.VALUE + " REAL NOT NULL " +
            " );";
    final String LEG = "CREATE TABLE " + Contract.Leg.TABLE + " (" +
            Contract.Leg._ID + " INTEGER PRIMARY KEY," +
            Contract.Leg.DAY + " INTEGER  NOT NULL, " +
            Contract.Leg.MONTH + " INTEGER  NOT NULL, " +
            Contract.Leg.YEAR + " INTEGER  NOT NULL, " +
            Contract.Leg.VALUE + " REAL NOT NULL " +
            " );";
    final String WAIST = "CREATE TABLE " + Contract.Waist.TABLE + " (" +
            Contract.Waist._ID + " INTEGER PRIMARY KEY," +
            Contract.Waist.DAY + " INTEGER  NOT NULL, " +
            Contract.Waist.MONTH + " INTEGER  NOT NULL, " +
            Contract.Waist.YEAR + " INTEGER  NOT NULL, " +
            Contract.Waist.VALUE + " REAL NOT NULL " +
            " );";
    final String ARM = "CREATE TABLE " + Contract.Arm.TABLE + " (" +
            Contract.Arm._ID + " INTEGER PRIMARY KEY," +
            Contract.Arm.DAY + " INTEGER  NOT NULL, " +
            Contract.Arm.MONTH + " INTEGER  NOT NULL, " +
            Contract.Arm.YEAR + " INTEGER  NOT NULL, " +
            Contract.Arm.VALUE + " REAL NOT NULL " +
            " );";
    // BODY WEIGHT TABLE
    final String WEIGHTS = "CREATE TABLE " + Contract.Weight.TABLE + " (" +
            Contract.Weight._ID + " INTEGER PRIMARY KEY," +
            Contract.Weight.DAY + " INTEGER NOT NULL, " +
            Contract.Weight.MONTH + " INTEGER NOT NULL, " +
            Contract.Weight.YEAR + " INTEGER NOT NULL, " +
            Contract.Weight.VALUE + " REAL NOT NULL " +
            " );";


    // CARDIO CHARTTTTTTTTTTTTTT
    final String SWIMMING = "CREATE TABLE " + Contract.Cardio_chart.Values.Swimming.TABLE + " (" +
            Contract.Cardio_chart.Values._ID + " INTEGER PRIMARY KEY," +
            Contract.Cardio_chart.Values.DAY + " INTEGER NOT NULL, " +
            Contract.Cardio_chart.Values.MONTH + " INTEGER NOT NULL, " +
            Contract.Cardio_chart.Values.YEAR + " INTEGER NOT NULL, " +
            Contract.Cardio_chart.Values.VALUE + " REAL NOT NULL " +
            " );";
    final String RUNNING = "CREATE TABLE " + Contract.Cardio_chart.Values.Running.TABLE + " (" +
            Contract.Cardio_chart.Values._ID + " INTEGER PRIMARY KEY," +
            Contract.Cardio_chart.Values.DAY + " INTEGER NOT NULL, " +
            Contract.Cardio_chart.Values.MONTH + " INTEGER NOT NULL, " +
            Contract.Cardio_chart.Values.YEAR + " INTEGER NOT NULL, " +
            Contract.Cardio_chart.Values.VALUE + " REAL NOT NULL " +
            " );";
    final String CARDIO = "CREATE TABLE " + Contract.Cardio_chart.Values.Cardio.TABLE + " (" +
            Contract.Cardio_chart.Values._ID + " INTEGER PRIMARY KEY," +
            Contract.Cardio_chart.Values.DAY + " INTEGER NOT NULL, " +
            Contract.Cardio_chart.Values.MONTH + " INTEGER NOT NULL, " +
            Contract.Cardio_chart.Values.YEAR + " INTEGER NOT NULL, " +
            Contract.Cardio_chart.Values.VALUE + " REAL NOT NULL " +
            " );";



    final String RUNNING_LIMITS = "CREATE TABLE " + Contract.Cardio_chart.Limits.SaveRunning_Limits.TABLE + " (" +
            Contract.Cardio_chart.Limits._ID + " INTEGER PRIMARY KEY," +
            Contract.Cardio_chart.Limits.HIGH + " INTEGER NOT NULL, " +
            Contract.Cardio_chart.Limits.LOW + " INTEGER NOT NULL " +
            " );";
    final String SWIMMING_LIMITS = "CREATE TABLE " + Contract.Cardio_chart.Limits.SaveSwimming_Limits.TABLE  + " (" +
            Contract.Cardio_chart.Limits._ID + " INTEGER PRIMARY KEY," +
            Contract.Cardio_chart.Limits.HIGH + " INTEGER NOT NULL, " +
            Contract.Cardio_chart.Limits.LOW + " INTEGER NOT NULL " +
            " );";
    final String CARDIO_LIMITS = "CREATE TABLE " + Contract.Cardio_chart.Limits.SaveCardio_Limits.TABLE  + " (" +
            Contract.Cardio_chart.Limits._ID + " INTEGER PRIMARY KEY," +
            Contract.Cardio_chart.Limits.HIGH + " INTEGER NOT NULL, " +
            Contract.Cardio_chart.Limits.LOW + " INTEGER NOT NULL " +
            " );";


    final String SAVE_RUNNING_NAME = "CREATE TABLE " + Contract.Cardio_chart.Names.SaveRunning_Name.TABLE + " (" +
            Contract.Cardio_chart.Names._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
            Contract.Cardio_chart.Names.NAME + " TEXT " +
            " );";
    final String SAVE_SWIMMING_NAME = "CREATE TABLE " + Contract.Cardio_chart.Names.SaveSwimming_Name.TABLE + " (" +
            Contract.Cardio_chart.Names._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
            Contract.Cardio_chart.Names.NAME + " TEXT " +
            " );";
    final String SAVE_CARDIO_NAME = "CREATE TABLE " + Contract.Cardio_chart.Names.SaveCardio_Name.TABLE + " (" +
            Contract.Cardio_chart.Names._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
            Contract.Cardio_chart.Names.NAME + " TEXT " +
            " );";
    db.execSQL(SQUAT);
    db.execSQL(DEADLIFT);
    db.execSQL(BENCH);
    db.execSQL(WAIST);
    db.execSQL(CHEST);
    db.execSQL(LEG);
    db.execSQL(ARM);
    db.execSQL(WEIGHTS);

    db.execSQL(SWIMMING);
    db.execSQL(RUNNING);
    db.execSQL(CARDIO);

    db.execSQL(RUNNING_LIMITS);
    db.execSQL(SWIMMING_LIMITS);
    db.execSQL(CARDIO_LIMITS);

    db.execSQL(SAVE_RUNNING_NAME);
    db.execSQL(SAVE_CARDIO_NAME);
    db.execSQL(SAVE_SWIMMING_NAME);


}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    db.execSQL("DROP TABLE IF EXISTS " + Contract.Squat.TABLE);
    db.execSQL("DROP TABLE IF EXISTS " + Contract.Deadlift.TABLE);
    db.execSQL("DROP TABLE IF EXISTS " + Contract.Bench.TABLE);
    db.execSQL("DROP TABLE IF EXISTS " + Contract.Weight.TABLE);
    db.execSQL("DROP TABLE IF EXISTS " + Contract.Waist.TABLE);
    db.execSQL("DROP TABLE IF EXISTS " + Contract.Leg.TABLE);
    db.execSQL("DROP TABLE IF EXISTS " + Contract.Arm.TABLE);
    db.execSQL("DROP TABLE IF EXISTS " + Contract.Chest.TABLE);

    db.execSQL("DROP TABLE IF EXISTS " + Contract.Cardio_chart.Values.Swimming.TABLE);
    db.execSQL("DROP TABLE IF EXISTS " + Contract.Cardio_chart.Values.Running.TABLE);
    db.execSQL("DROP TABLE IF EXISTS " + Contract.Cardio_chart.Values.Cardio.TABLE);

    db.execSQL("DROP TABLE IF EXISTS " + Contract.Cardio_chart.Limits.SaveRunning_Limits.TABLE);
    db.execSQL("DROP TABLE IF EXISTS " + Contract.Cardio_chart.Limits.SaveSwimming_Limits.TABLE);
    db.execSQL("DROP TABLE IF EXISTS " + Contract.Cardio_chart.Limits.SaveCardio_Limits.TABLE);

    db.execSQL("DROP TABLE IF EXISTS " + Contract.Cardio_chart.Names.SaveRunning_Name.TABLE);
    db.execSQL("DROP TABLE IF EXISTS " + Contract.Cardio_chart.Names.SaveSwimming_Name.TABLE);
    db.execSQL("DROP TABLE IF EXISTS " + Contract.Cardio_chart.Names.SaveCardio_Name.TABLE);

    onCreate(db);
}

}

合同

public class Contract {
public static final String AUTHORITY = "developer.mohab.gymee";
public static final Uri BASE_CONTENT_URI = Uri.parse("content://" + AUTHORITY);
public static final String PATH_SQUAT = "squat" ;
public static final String PATH_BENCH = "bench" ;
public static final String PATH_DEADLIFT = "deadlift" ;
public static final String PATH_WAIST = "waist" ;
public static final String PATH_CHEST = "chest" ;
public static final String PATH_ARM = "arm" ;
public static final String PATH_LEG = "leg" ;
public static final String PATH_WEIGHT = "weight" ;
// cardio chart
public static final String PATH_RUNNING = "running" ;
public static final String PATH_SWIMMING = "swimming" ;
public static final String PATH_CARDIO = "cardio" ;
public static final String PATH_RUNNINGLIMITS ="runninglimits";
public static final String PATH_SWIMMINGLIMITS ="swimminglimits";
public static final String PATH_CARDIOLIMITS ="cardiolimits";
public static final String PATH_SAVERUNNING_NAME ="saverunningname";
public static final String PATH_SAVESWIMMING_NAME ="saveswimmingname";
public static final String PATH_SAVECARDIO_NAME ="savecardioname";


// those three for weights
// SMONTH  is month formatted as first three characters ex FAB,MAR,JUN
public static final class Squat implements BaseColumns{
    public static final Uri CONTENT_URI =
            BASE_CONTENT_URI.buildUpon().appendPath(PATH_SQUAT).build();
    public static final String TABLE = PATH_SQUAT;
    public static final String VALUE = "weight" ;
    public static final String DAY = "day";
    public static final String MONTH = "month";
    public static final String YEAR = "year";
    public static Uri insertedRow(long id) {
        return ContentUris.withAppendedId(CONTENT_URI, id);
    }
}
public static final class Bench implements BaseColumns{
    public static final Uri CONTENT_URI =
            BASE_CONTENT_URI.buildUpon().appendPath(PATH_BENCH).build();
    public static final String TABLE = PATH_BENCH;
    public static final String VALUE = "weight" ;
    public static final String DAY = "day";
    public static final String MONTH = "month";
    public static final String YEAR = "year";
    public static Uri insertedRow(long id) {
        return ContentUris.withAppendedId(CONTENT_URI, id);
    }
}
public static final class Deadlift implements BaseColumns {
    public static final Uri CONTENT_URI =
            BASE_CONTENT_URI.buildUpon().appendPath(PATH_DEADLIFT).build();
    public static final String TABLE = PATH_DEADLIFT;
    public static final String VALUE = "weight";
    public static final String DAY = "day";
    public static final String MONTH = "month";
    public static final String YEAR = "year";
    public static Uri insertedRow(long id) {
        return ContentUris.withAppendedId(CONTENT_URI, id);
    }
}
// those four for bodyRatio
public static final class Waist implements BaseColumns{
    public static final Uri CONTENT_URI =
            BASE_CONTENT_URI.buildUpon().appendPath(PATH_WAIST).build();
    public static final String TABLE = PATH_WAIST;
    public static final String VALUE = "measure";
    public static final String DAY = "day";
    public static final String MONTH = "month";
    public static final String YEAR = "year";
    public static Uri insertedRow(long id) {
        return ContentUris.withAppendedId(CONTENT_URI, id);
    }
}
public static final class Chest implements BaseColumns{
    public static final Uri CONTENT_URI =
            BASE_CONTENT_URI.buildUpon().appendPath(PATH_CHEST).build();
    public static final String TABLE  =  PATH_CHEST;
    public static final String VALUE ="measure";
    public static final String DAY = "day";
    public static final String MONTH = "month";
    public static final String YEAR = "year";
    public static Uri insertedRow(long id) {
        return ContentUris.withAppendedId(CONTENT_URI, id);
    }
}
public static final class Arm implements BaseColumns{
    public static final Uri CONTENT_URI =
            BASE_CONTENT_URI.buildUpon().appendPath(PATH_ARM).build();
    public static final String TABLE = PATH_ARM;
    public static final String VALUE = "measure";
    public static final String DAY = "day";
    public static final String MONTH = "month";
    public static final String YEAR = "year";
    public static Uri insertedRow(long id) {
        return ContentUris.withAppendedId(CONTENT_URI, id);
    }
}
public static final class Leg implements BaseColumns{
    public static final Uri CONTENT_URI =
            BASE_CONTENT_URI.buildUpon().appendPath(PATH_LEG).build();
    public static final String TABLE = PATH_LEG;
    public static final String VALUE = "measure";
    public static final String DAY = "day";
    public static final String MONTH = "month";
    public static final String YEAR = "year";
    public static Uri insertedRow(long id) {
        return ContentUris.withAppendedId(CONTENT_URI, id);
    }
}
public static final class Weight implements BaseColumns{
    public static final Uri CONTENT_URI =
            BASE_CONTENT_URI.buildUpon().appendPath(PATH_WEIGHT).build();
    public static final String TABLE =PATH_WEIGHT;
    public static final String VALUE ="weight";
    public static final String DAY = "day";
    public static final String MONTH = "month";
    public static final String YEAR = "year";
    public static Uri insertedRow(long id) {
        return ContentUris.withAppendedId(CONTENT_URI, id);
    }
}


public static class Cardio_chart {
    // this class for cardio chart and contain three graphs each one has value,limits and name classes  .

    public static class Values {
        public static  String VALUE = "value";
        public static  String DAY = "day";
        public static  String MONTH = "month";
        public static  String YEAR = "year";
        public static  String _ID = "_id";

        public static final class Running  {
            public static final Uri CONTENT_URI =
                    BASE_CONTENT_URI.buildUpon().appendPath(PATH_RUNNING).build();
            public static final String TABLE = PATH_RUNNING;

            public static Uri insertedRow(long id) {
                return ContentUris.withAppendedId(CONTENT_URI, id);
            }
        }

        public static final class Swimming  {
            public static final Uri CONTENT_URI =
                    BASE_CONTENT_URI.buildUpon().appendPath(PATH_SWIMMING).build();
            public static final String TABLE = PATH_SWIMMING;

            public static Uri insertedRow(long id) {
                return ContentUris.withAppendedId(CONTENT_URI, id);
            }
        }

        public static final class Cardio  {
            public static final Uri CONTENT_URI =
                    BASE_CONTENT_URI.buildUpon().appendPath(PATH_CARDIO).build();
            public static final String TABLE = PATH_CARDIO;

            public static Uri insertedRow(long id) {
                return ContentUris.withAppendedId(CONTENT_URI, id);
            }
        }
    }
    // body weight

    public static class Limits {
        public static final String HIGH = "high";
        public static final String LOW = "low";
        public static final String _ID = "_id";


        public static final class SaveRunning_Limits  {
            public static final Uri CONTENT_URI =
                    BASE_CONTENT_URI.buildUpon().appendPath(PATH_RUNNINGLIMITS).build();
            public static final String TABLE = PATH_RUNNINGLIMITS;

        }

        public static final class SaveSwimming_Limits  {
            public static final Uri CONTENT_URI =
                    BASE_CONTENT_URI.buildUpon().appendPath(PATH_SWIMMINGLIMITS).build();
            public static final String TABLE = PATH_SWIMMINGLIMITS;

        }

        public static final class SaveCardio_Limits  {
            public static final Uri CONTENT_URI =
                    BASE_CONTENT_URI.buildUpon().appendPath(PATH_CARDIOLIMITS).build();
            public static final String TABLE = PATH_CARDIOLIMITS;

        }
    }

    public static class Names {
        public static final String NAME = "name";
        public static final String _ID = "_id";


        public static final class SaveRunning_Name  {
            public static final Uri CONTENT_URI =
                    BASE_CONTENT_URI.buildUpon().appendPath(PATH_SAVERUNNING_NAME).build();
            public static final String TABLE = PATH_SAVERUNNING_NAME;

        }

        public static final class SaveSwimming_Name {
            public static final Uri CONTENT_URI =
                    BASE_CONTENT_URI.buildUpon().appendPath(PATH_SAVESWIMMING_NAME).build();
            public static final String TABLE = PATH_SAVESWIMMING_NAME;

        }

        public static final class SaveCardio_Name  {
            public static final Uri CONTENT_URI =
                    BASE_CONTENT_URI.buildUpon().appendPath(PATH_SAVECARDIO_NAME).build();
            public static final String TABLE = PATH_SAVECARDIO_NAME;

        }
    }
}

}

数据库过滤类

public class DatabaseFilter  {
static Uri name_table ;
static Uri limit_table ;
static Uri value_table ;
static  Context context ;
static MainActivity activity ;
static int postition ;
static String ValueTable_name;
static String LimitsTable_name;
static String NameTable_name;

DatabaseFilter(Context c) {
    this.context =c ;
    activity = (MainActivity) c;

}

public static Uri NameTable(){
    postition = MainActivity.filter();


    switch (postition){
        case 0 :{
            name_table = Contract.Cardio_chart.Names.SaveRunning_Name.CONTENT_URI ;
            break;

        }
        case 1 :{
            name_table = Contract.Cardio_chart.Names.SaveSwimming_Name.CONTENT_URI ;
            break;

        }
        case 2 :{
            name_table = Contract.Cardio_chart.Names.SaveCardio_Name.CONTENT_URI ;
            break;

        }

    }
    return name_table ;
}

public static  Uri LimitTable(){
    postition = MainActivity.filter();

    switch (postition){
        case 0 :{
            limit_table = Contract.Cardio_chart.Limits.SaveRunning_Limits.CONTENT_URI ;
            break;

        }
        case 1 :{
            limit_table = Contract.Cardio_chart.Limits.SaveSwimming_Limits.CONTENT_URI ;
            break;

        }
        case 2 :{
            limit_table = Contract.Cardio_chart.Limits.SaveCardio_Limits.CONTENT_URI ;
            break;

        }
    }
    return limit_table ;
}
public static  Uri ValueTable(){
    postition = MainActivity.filter();


    switch (postition){
        case 0 :{
            value_table = Contract.Cardio_chart.Values.Running.CONTENT_URI ;
            break;

        }
        case 1 :{
            value_table = Contract.Cardio_chart.Values.Swimming.CONTENT_URI ;
            break;

        }
        case 2 :{
            value_table = Contract.Cardio_chart.Values.Cardio.CONTENT_URI ;
            break;

        }

    }
    return value_table ;
}

public static String  valueTable_Name(){
    postition = MainActivity.filter();


    switch (postition){
        case 0 :{
            ValueTable_name = Contract.Cardio_chart.Values.Running.TABLE ;
            break;

        }
        case 1 :{
            ValueTable_name = Contract.Cardio_chart.Values.Swimming.TABLE ;
            break;

        }
        case 2 :{
            ValueTable_name = Contract.Cardio_chart.Values.Cardio.TABLE ;
            break;

        }

    }
    return ValueTable_name;
}
public static String LimitsTable_Name(){
    postition = MainActivity.filter();

    switch (postition){

        case 0 :{

            LimitsTable_name = Contract.Cardio_chart.Limits.SaveRunning_Limits.TABLE ;
            break;

        }
        case 1 :{


            LimitsTable_name = Contract.Cardio_chart.Limits.SaveSwimming_Limits.TABLE ;
            break;

        }
        case 2 :{
            LimitsTable_name = Contract.Cardio_chart.Limits.SaveCardio_Limits.TABLE ;
            break;

        }

    }
    return LimitsTable_name;
}
public static String  NameTable_Name(){

    postition = MainActivity.filter();

    switch (postition){
        case 0 :{
            NameTable_name = Contract.Cardio_chart.Names.SaveRunning_Name.TABLE ;
            break;
        }
        case 1 :{
            NameTable_name = Contract.Cardio_chart.Names.SaveSwimming_Name.TABLE ;
            break;
        }
        case 2 :{
            NameTable_name = Contract.Cardio_chart.Names.SaveCardio_Name.TABLE ;
            break;
        }

    }
    return NameTable_name;
}

}

插入函数

  public void input(float Value) {
    SimpleDateFormat sdf = new SimpleDateFormat("d,M,y");
    String currentDateandTime = sdf.format(new Date());
    String[] s = currentDateandTime.split(",");
    int day = Integer.parseInt(s[0]);
    int month = Integer.parseInt(s[1]);
    int year = Integer.parseInt(s[2]);

    SQLiteDatabase db = database.getWritableDatabase();
    ContentValues values = new ContentValues();
    values.put(Contract.Cardio_chart.Values.VALUE, Value);
    values.put(Contract.Cardio_chart.Values.DAY, day);
    values.put(Contract.Cardio_chart.Values.MONTH, month);
    values.put(Contract.Cardio_chart.Values.YEAR, year);
    db.insert(DatabaseFilter.ValueTable_name, null, values);
    db.close();
    addEntries(0, 0, true);
}

共有1个答案

轩辕实
2023-03-14

来自弗兰克·N·斯坦的评论,插入语句中的错误

db.insert(数据库过滤器。ValueTable_name,null,值);

虫子

DatabaseFilter.ValueTable_name

更正

DatabaseFilter.valueTable_Name()
 类似资料:
  • 问题内容: 我在堆栈中搜索,但没有一个达到最终答案。我的查询是这样的: 运行时,我收到语法分析错误: 我不知道该如何解决,问题出在哪里? 问题答案: 您需要稍微更改语法,请尝试以下操作:

  • 问题内容: 我有一个小查询,并在其旁边放了一个联合查询。但是,联合中存在语法错误。 这是我收到的错误 问题答案: 我知道出了什么问题。您必须在查询的末尾且仅在末尾下订单。它给了我一个错误,因为它认为查询已结束。 做到了。

  • 这是我的代码: LogCat说:12-11 23:43:50.553:E/AndroidRuntime(3706):android.database.sqlite.sqliteException:“create ;table”附近:语法错误(代码1):,编译时:create ;table PapersTable(_id integer ;primary ;key ;autoincrement,ti

  • 我只是想创建一个包含一列的表,并向其中添加一些值,但我得到了两个错误。一种是取消对db.close()的注释;句柄关闭太快,另一个是下面是代码。

  • 问题内容: 我创建了这个表: 我尝试运行以下postgres脚本: 为什么会出现此语法错误? 问题答案: 支持版本 根据以上@klin的评论,仅 PostgreSQL 9.5及 更高版本支持。 独特的约束 在添加唯一索引。目前,该列上没有任何约束,因此该列上没有冲突的可能性。 但是,如果您不希望该列是唯一的,那么您打算遇到什么冲突/您希望通过该操作解决的问题是什么? 请参阅https://www.

  • 问题内容: 我键入的代码与《 Linux命令行:完整介绍》 (第369页)相同,但提示错误: 代码是这样的: 我想了解是什么导致了错误?如何修改代码?我的系统是Ubuntu。 问题答案: 和之间必须有一个空格,如下所示: 这些(及其组合)也都是 不正确的 : 另一方面,这些都可以: 顺便说一句,这些是等效的: 这些也等效: 而且,您的脚本的中间部分应该像这样更好: (我也将引号中的引号删除了,因为