سؤال

I try to delete from a table where there is a date field (represented as a string). I'd like to do it by the following statement:

Object result=new Delete().from(Information.class).where("Date>=?", date.replace(".","-")).execute();

It seems that nothing was deleted, the result variable is null.

I have 2 questions:

  1. How can I get the number of the deleted objects?

  2. How can I use a where with a date variable?

هل كانت مفيدة؟

المحلول

The problem was on the object side, not the ActiveAndroid/SQLite side. SQLite can use dates for comparison but the source date has to be LocalDateTime. As you can see, I've been using Strings so the comparison gave false results.

نصائح أخرى

Dont you have to add the (') char to a date?

Object result=new Delete().from(Information.class).where("Date>='?" + "'", date.replace(".","-") ).execute();

Like that?

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top