You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So I am using a DataBase whit dates , and I have a code that retrieves the maxID of that database(number of dates) and then , I have a for loop that goes trough the database and selects a date (String) and parses it in to a date and the sets the background for that date on the calendar . The problem is that its not setting the background for blue.
The code that gets the maxID and the Dates from the database :
` public int getLastId() {
String query = "SELECT MAX(id) AS max_id FROM " + TABLE_NAME;
Cursor cursor = database.rawQuery(query, null);
int id = 0;
if (cursor.moveToFirst())
{
do
{
id = cursor.getInt(0);
} while(cursor.moveToNext());
}
cursor.close();
return id;
}
public String getDates(int numero){
String date = "";
String last_query = "SELECT " + COL_4 + " FROM " + TABLE_NAME + " WHERE " + COL_1 + " = '" + numero + "'";
Cursor c = database.rawQuery(last_query, null);
if (c != null && c.moveToFirst())
{
date = c.getString(c.getColumnIndex("DIA")); // Return Value
}
c.close();
return date;
}
}`
The code that uses those methods and setTHEbackgroundColor for each of those dates: ` public void addToCalendar(){
myDB = CustomApplication.getDatabaseHelper();
ColorDrawable blue = new ColorDrawable(Color.BLUE);
for(int i=0;i == myDB.getLastId();i++){
String dt = myDB.getDates(i);
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("dd-MM-yyyy");
Date teste = null;
try {
teste = sdf.parse(dt);
caldroidFragment.setBackgroundDrawableForDate(blue,teste);
} catch (ParseException e) {
e.printStackTrace();
}
}
}
`
The text was updated successfully, but these errors were encountered:
So I am using a DataBase whit dates , and I have a code that retrieves the maxID of that database(number of dates) and then , I have a for loop that goes trough the database and selects a date (String) and parses it in to a date and the sets the background for that date on the calendar . The problem is that its not setting the background for blue.
The code that gets the maxID and the Dates from the database :
` public int getLastId() {
String query = "SELECT MAX(id) AS max_id FROM " + TABLE_NAME;
Cursor cursor = database.rawQuery(query, null);
int id = 0;
if (cursor.moveToFirst())
{
do
{
id = cursor.getInt(0);
} while(cursor.moveToNext());
}`
The code that uses those methods and setTHEbackgroundColor for each of those dates: ` public void addToCalendar(){
`
The text was updated successfully, but these errors were encountered: