public class DbManager
extends android.database.sqlite.SQLiteOpenHelper
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
TAG |
Constructor and Description |
---|
DbManager(android.content.Context context) |
Modifier and Type | Method and Description |
---|---|
void |
closeDb()
Close the db when finished using it.
|
long |
createNewDatesRing(java.lang.String datePut,
java.lang.String dateRemoved,
int isRunning)
Create a new contact only if non existent:
Example: The contact named Toto does not exist, so let's create it
|
long |
createNewPause(long entryId,
java.lang.String dateRemoved,
java.lang.String datePut,
int isRunning)
Create a new Pause
|
void |
deleteEntry(long entryId)
Delete a entry
|
void |
deletePauseEntry(long pauseId)
Delete pause in db
|
void |
deleteSpermoEntry(long entryId) |
void |
endPause(long entryId)
End pause for given sessionId
|
void |
endSession(long entryId)
Set a session as finished for given entryId
|
java.util.ArrayList<RingSession> |
getAllDatasForAllEntrys()
This function is used to backup into a file
|
java.util.ArrayList<RingSession> |
getAllDatasForAllPauses()
This function is used to backup into a file
|
java.util.LinkedHashMap<java.lang.Integer,RingSession> |
getAllDatasForMainList(boolean isDesc)
EditEntry
Get the datas list for a the main List
|
java.util.ArrayList<RingSession> |
getAllPausesForId(long entryId,
boolean isDesc)
Return a array list of all pauses for given id
|
java.util.HashMap<java.lang.Integer,java.lang.String> |
getAllRunningSessions()
Check if there is running sessions.
|
java.util.LinkedHashMap<java.lang.Integer,Spermograms> |
getAllSpermograms() |
static java.lang.String |
getDBName()
Get the dbName
|
RingSession |
getEntryDetails(long entryId)
Get the details for a entry
|
java.util.ArrayList<RingSession> |
getHistoryForMainView(boolean isDesc) |
RingSession |
getLastRunningEntry()
Get the last running entry
|
RingSession |
getLastRunningPauseForId(long entryId)
Get the last running entry
|
Spermograms |
getSpermoEntryForId(long entryId)
Get the details for spermogram
|
int |
getVersion() |
long |
importNewSpermo(java.lang.String uri) |
void |
onCreate(android.database.sqlite.SQLiteDatabase db)
If the db does not exist, create it with thoses fields.
|
void |
onUpgrade(android.database.sqlite.SQLiteDatabase db,
int i,
int i1)
If you plan to improve the database, you might want to use this function as a automated
upgrade tool for db.
|
java.util.ArrayList<RingSession> |
searchEntryInDb(java.lang.String date) |
void |
updateDatesRing(long id,
java.lang.String datePut,
java.lang.String dateRemoved,
int isRunning)
Updated the datas contained in a entry
|
void |
updatePause(long pauseId,
java.lang.String dateRemoved,
java.lang.String datePut,
int isRunning)
Updated the datas contained in a entry
|
void |
updateSpermogram(long entryId,
java.lang.String new_spermogram_date) |
public static final java.lang.String TAG
public void onCreate(android.database.sqlite.SQLiteDatabase db)
onCreate
in class android.database.sqlite.SQLiteOpenHelper
db
- The database Objectpublic static java.lang.String getDBName()
public int getVersion()
public void onUpgrade(android.database.sqlite.SQLiteDatabase db, int i, int i1)
onUpgrade
in class android.database.sqlite.SQLiteOpenHelper
db
- the Dbi
- Old DB versioni1
- New DB versionpublic java.util.LinkedHashMap<java.lang.Integer,RingSession> getAllDatasForMainList(boolean isDesc)
public java.util.ArrayList<RingSession> getHistoryForMainView(boolean isDesc)
public long createNewDatesRing(java.lang.String datePut, java.lang.String dateRemoved, int isRunning)
dateRemoved
- date at which user has removed the protectiondatePut
- date at which user has put the protectionisRunning
- if the current session is runningpublic java.util.HashMap<java.lang.Integer,java.lang.String> getAllRunningSessions()
public void updateDatesRing(long id, java.lang.String datePut, java.lang.String dateRemoved, int isRunning)
id
- the entry we want to updatedatePut
- the new datePutdateRemoved
- the new dateRemovedisRunning
- the new isRunningpublic RingSession getEntryDetails(long entryId)
entryId
- the id we want to have details forpublic void deleteEntry(long entryId)
entryId
- the id of the contact we want to deletepublic void endSession(long entryId)
entryId
- set the session as finished for given idpublic void endPause(long entryId)
entryId
- sessionIdpublic long createNewPause(long entryId, java.lang.String dateRemoved, java.lang.String datePut, int isRunning)
entryId
- the id to link to the pausedateRemoved
- the date the user stopped wearing protectiondatePut
- the date the user put the new protection againisRunning
- if the pause is runningpublic void updatePause(long pauseId, java.lang.String dateRemoved, java.lang.String datePut, int isRunning)
pauseId
- the entry we want to updatedatePut
- the new datePutdateRemoved
- the new dateRemovedisRunning
- the new isRunningpublic java.util.ArrayList<RingSession> searchEntryInDb(java.lang.String date)
public RingSession getLastRunningEntry()
public RingSession getLastRunningPauseForId(long entryId)
public java.util.ArrayList<RingSession> getAllDatasForAllEntrys()
public java.util.ArrayList<RingSession> getAllPausesForId(long entryId, boolean isDesc)
entryId
- id to look forisDesc
- set if the pauses should be desc or notpublic void deletePauseEntry(long pauseId)
pauseId
- the pauseId to deletepublic java.util.ArrayList<RingSession> getAllDatasForAllPauses()
public long importNewSpermo(java.lang.String uri)
public Spermograms getSpermoEntryForId(long entryId)
entryId
- the id we want to have details forpublic void updateSpermogram(long entryId, java.lang.String new_spermogram_date)
public java.util.LinkedHashMap<java.lang.Integer,Spermograms> getAllSpermograms()
public void deleteSpermoEntry(long entryId)
public void closeDb()