jeudi 5 mai 2016

Inserting a Date in SQLite and then compare for a specific interval

I have on table which contains a Date column as "Time DATE" now I am using content Values to insert data into it. Content Values takes input as cv.put(String Key,String Value) now how do I insert a Date Data in it and after insertion when i insert next time it should check for interval like 5 min before and after and if condition fails some message will be thrown. The only Problem is I can not store Date as Date. I need some information how I can achieve that.

public long InsertDetails (String name, String Item, int amount, Date Time){
        ContentValues values = new ContentValues ();``
        CV.put(Dbhelper.Name,  name );
        CV.put(Dbhelper.Item, Item);
        CV.put(Dbhelper.Amount, amount);
        CV.put(Dbhelper.DATE, String.valueOf(Time));//this take (String,String)
        long id=db.insert(Dbhelper.TableName,null,CV)
        return id;
       }

After insertion i can not compare the time values with the next insertion value as the values stored are in string. How do i achieve it ,Note before Inserting I need to compare time interval also.

Aucun commentaire:

Enregistrer un commentaire