I am creating an application for Android. I am using Realm as a Database. Realm working fine in the whole app. Now I want to insert some data when from "NotificationExtender" class (This will help to receive and customise onesignal notification). Which leads to outOfMemory error How can I handle this.
My sample code: In My Notification class I am doing this
RealmLibrary.insertMessageToDBFromNotificationReceiver(
jsonObject.getString("data"),
jsonObject.getString("groupKey"),
jsonObject.getString("groupKey"),
mContext);
And in my RealmLibrary class:
Realm realm = getRealm(applicationContext);
realm.beginTransaction();
ChatMessages chatmsg = realm.where(ChatMessages.class)
.equalTo("gUid", gUID).findFirst();
int count = 0;
if (chatmsg == null) {
// Create an new object
chatmsg = realm.createObject(ChatMessages.class);
count = 1;
chatmsg.setgUid(gUID);
} else {
}
realm.commitTransaction();
Also my getRealm method:
public static Realm getRealm(Context context) {
return Realm.getDefaultInstance();
}
How can i handle this outOf memory. Please anyone tell me which code leads to the error. Which is the not efficient code..
Note : it is just a sample code. If any details needed pls leave your comments.
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)