Saturday 11 January 2014

Android: Get boolean value from the database

Kindly read about SQLite datatypes.
Here is how can we retrieve boolean value

           try
{
String query = "Select 'check_in_time', 'total_hours', 'active' from hours where job_title = '" + taskName + "'";
cursor = adtDB.rawQuery(query, null);
while (cursor.moveToNext())
{
long checkInTime = cursor.getLong(0);
long totalHours = cursor.getLong(1);
boolean active = cursor.getString(2).equalsIgnoreCase("TRUE");
}
}
catch (Exception e)
{
Utils.println(e.getMessage());
}
finally
{
if (cursor != null) cursor.close();
close();

No comments:

Post a Comment