mardi 1 septembre 2015

SQLiteException near "null" : syntax error

First,there is similar questions like 1 , 2 , 3 , 4 , 5 but no answer mentioned solve this problem .

LogCat error

09-02 05:27:31.213: E/SQLiteDatabase(8442): Error inserting day=2 month=9 value=3.0 year=2015 09-02 05:27:31.213: E/SQLiteDatabase(8442): android.database.sqlite.SQLiteException: near "null": syntax error (code 1): , while compiling: INSERT INTO null(day,month,value,year) VALUES (?,?,?,?) 09-02 05:27:31.213: E/SQLiteDatabase(8442): at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method) 09-02 05:27:31.213: E/SQLiteDatabase(8442): at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:895) 09-02 05:27:31.213: E/SQLiteDatabase(8442): at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:506) 09-02 05:27:31.213: E/SQLiteDatabase(8442): at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588) 09-02 05:27:31.213: E/SQLiteDatabase(8442): at android.database.sqlite.SQLiteProgram.(SQLiteProgram.java:58) 09-02 05:27:31.213: E/SQLiteDatabase(8442): at android.database.sqlite.SQLiteStatement.(SQLiteStatement.java:31) 09-02 05:27:31.213: E/SQLiteDatabase(8442): at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1469) 09-02 05:27:31.213: E/SQLiteDatabase(8442): at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1341) 09-02 05:27:31.213: E/SQLiteDatabase(8442): at developer.mohab.gymee.Cardio.MainActivity.input(MainActivity.java:210) 09-02 05:27:31.213: E/SQLiteDatabase(8442): at developer.mohab.gymee.Cardio.InsertDialogue.onClick(InsertDialogue.java:47)

Snippet from Database Table that return error

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 " +
            " );";

Database class

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);
}

}

Contract

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;

        }
    }
}

}

DatabaseFilter class

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;
}

}

Insert function

  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);
}

Aucun commentaire:

Enregistrer un commentaire