What's the correct way to create a Room Entity with two possible Parents?

244
August 26, 2017, at 08:50 AM

I am using Room in Android for the first time. I have one Entity Comment which is part of a tree structure. Some comments will be the child of a Post while others will be the children of another Comment.

The following is my entity declaration

@Entity(tableName = "comments,
    foreignKeys = {
        @ForeignKey(entity = Post.class, parentColumns = "uid",
                childColumns = "post_uid", onDelete = CASCADE),
        @ForeignKey(entity = Comment.class, parentColumns = "uid",
                childColumns = "comment_uid", onDelete = CASCADE)
    }
)
public class Comment {
   ...
}

I cant see an option like nullable or required for the Foreign Key, so what is the correct way to declare that the keys can be missing?

READ ALSO
how to add search filter in firebase recyclerview ui

how to add search filter in firebase recyclerview ui

i am trying to add search filter in action bar in firebase recyclerview UI but it does not work

370
How to compare value and delete from firebase realtime database?

How to compare value and delete from firebase realtime database?

I am using Firebase realtime database in Android app, and have data like this:

392
Android XmlPullParser Expected a quoted string (position:DOCDECL @1:50

Android XmlPullParser Expected a quoted string (position:DOCDECL @1:50

I'm writing an Android unit test and is attempting to use a XmlPullParser to read and parse the following URL:

368
How to create a Menu Bottom of this type in Android?

How to create a Menu Bottom of this type in Android?

enter image description hereI am developing an app in android and I want to implement a menu similar to the image, does anyone have any examples of how to do it?

260