I have an object
public class ArticleList extends RealmObject {
@PrimaryKey
private String id;
private String title;
private String subtitle;
private String image;
private String category;
}
What I want to do is to fetch result from Realm and them convert result to ArticleList[]
Fetch I do by using
RealmResults<ArticleList> results = realm.where(ArticleList.class).equalTo("category", "CategoryName").findAll();
What do I have to do next to get an array of objects ?
You set everything properly in Realm schema, you store there the array, everything works great till now. Now, you fetch it from Realm and you get your object with the property which isn't array but an Object!
Step 1: Go to Android Studio, open "Device File Explorer" from the right-side panel, and then select your emulator. Step 2: Get the Realm file for our app. For this, open the folder named data as highlighted above, and then go to the data folder again.
Android Realm Database Tutorial. This is android realm database tutorial. Realm is an open source database that can be used to store data locally in android. It is used by over 100k developers and is a good alternative of SQLite.
Big problem, for consideration to not use Realm. Imagine you have an object which has property of array of objects. You set everything properly in Realm schema, you store there the array, everything works great till now. Now, you fetch it from Realm and you get your object with the property which isn't array but an Object!
Simplest to convert into java ArrayList:
ArrayList<People> list = new ArrayList(mRealm.where(People.class).findAll());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With