android


How to query on current date and bring back objects in Realm that contains it?


So working on a android app using the realm database. I can find out the current date, which I can do using Calendar.getInstance(), but what I want to know is how I can use a realm model to actually store different weekdays for a object.
My model looks like this:
public class Habit extends RealmObject{
private static int id=0;
private String name;
private Date created;
private ArrayList<Date> repeat;
private Date updated;
private Date reminder;
private int target;
private int tracker;
// getter and setters
}
I am trying to store the days that would be repeating (so max 7 or daily, and at least 1 as minimum) in the ArrayList of repeat since Realm doesn't accept Calendar.
I would create the object and then pass in the appropriate data to fill in the fields and based on the number of days selected send those date objects as well (for example Repeat on Monday, Tuesday, Friday). I would then query on the realm db to bring back all objects that contain the current date gotten by the calendar.getInstance(). At least this is what I was thinking.
The problem however is that at the moment I am taking a string input to determine which days the user wants the item to repeat, how do i translate this to a date item that is the weekday/weekend and then store it in my realm object?
Any help or suggestions would really help in getting this to work. Also if any extra code would help let me know what I can add.
Thank you.
private ArrayList<Date> repeat;
Realm does not support list of primitives, and Date is considered a primitive.
You need to create a class-specific object that has a Date parameter.
public class Habit extends RealmObject{
private static int id=0;
private String name;
private Date created;
private RealmList<HabitDate> repeat;
private Date updated;
private Date reminder;
private int target;
private int tracker;
// getter and setters
}
public class HabitDate extends RealmObject {
private Date date;
private Habit habit; // <-- because query across `#LinkingObjects` is 3.3+
}

Related Links

how can I use frames on phone gap and inappbrowser
Android Year Month and Time Zone
Does jayway maven plugin option <manifestVersioncode> really works for Android app?
Intent/action from notification not passed on when user clicks on notification
set orientation portrait phonegap android
Android custum listview layout issue
Android JNI Using Pre built .so file in C Code
Open Activity with backwards to MainActivity in my app
Problems Adding TextView Programmatically Without Erasing Views in XML - Android
ndk-build: Header file of static prebuilt static library not found even on LOAD_STATIC_LIBRARY
Android studio. Module not specified after import
Android Java getId() name not int value [duplicate]
Ntlm code works on only Samsung devices
Webview - open links in external apps and browsers / android
alarm never triggers , as it should do android
Enabling GPS programmatically, causes the GPS indicator to flash while the GPS button is disabled

Categories

HOME
sonarqube
phpword
gridview
fuelux
css3
pagination
rdbms
themes
components
socket.io
javacc
web-hosting
tail
gembox-spreadsheet
crystal-reports-2013
missing-data
augeas
google-chrome-app
distribution
opengl-es-3.0
comsol
symbol
job-scheduling
red5
gmm
topology
apache2.4
jquery-ias
ios10.2
displaytag
google-api-client
pic32
gitlab-api
simplecv
installshield-le
activexobject
modalviewcontroller
roblox
google-knowledge-graph
xdocreport
node-mssql
opensmpp
doc
trigonometry
vmware-fusion
softmax
glm-math
outputcache
flask-login
facebook-social-plugins
opencmis
phpdbg
vaadin-elements
pom.xml
mschart
podscms
modelsim
java-websocket
objectscript
swingworker
structuremap4
change-tracking
simplepie
builtins
redistributable
hadoop-2.7.2
myspace
vulcanize
burrows-wheeler-transform
file-uri
dimension
query-by-example
hadoop-partitioning
ikiwiki
relativelayout
roadkill-wiki
django-urls
lasso
snackbar
ssis-data-flow
spy++
raygun
personalization
rfc5322
light
jammer
kendo-dataviz
isqlquery
neos-server
mvc-editor-templates
ui-select2
panda3d
xcode3.2
dajaxice
appjs
convention
filemerge
winmain
timthumb
objective-j
ajax-polling
isapi-extension
qtabbar
tui
linfu-dynamicproxy
wspbuilder

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App