realm

shipping Android app with a .realm file and use it as a default database

会有一股神秘感。 提交于 2019-12-14 03:34:38
问题 i have a default.realm file in my " assets/default.realm " folder, I am not able to make it as a default realm database realm.getDefaultInstance(); src= new File("assets/default.realm"); dst=new File("/data/data/" + context.getPackageName() + "/files/"); if (!(realm.isEmpty())) { Log.v("DB","already there!!"); } else { try { copyFile(src,dst); } catch (IOException e) { Log.v("DB","Wrong Path!"); } } void copyFile(File src, File dst) throws IOException { FileChannel inChannel = new

How can I shuffle the contents of a RealmResults object

家住魔仙堡 提交于 2019-12-14 01:58:25
问题 I have a RealmResults object which holds output of a .where.findAll() query. I am showing contents of this object in a RecyclerView, but since the contents of the RealmResults object are static, it shows same set of records evertime the RecyclerView is opened. I want to shuffle (randomize) the contents of RealmResults so that I can show different values that are in the RealmResults in my RecyclerView. Please suggest some possible ways in which I can perform the same. 回答1: You should not

Update mutiple rows in table using Realm in Android

怎甘沉沦 提交于 2019-12-14 01:10:51
问题 I am using Realm to store my values in local database. My requirement is that i need to change one field status=1 based on some condition. I have tried following method to accomplish this task. And it is working fine. RealmResults<NotificationOrder> notificationOrders=realm .where(NotificationOrder.class) .equalTo(RealmConstants.TBL_NOTIFICATION_ORDER.property_id,ConstantMethod.getPreference(getActivity(),UserDefault.kPropertyId)) .equalTo(RealmConstants.TBL_NOTIFICATION_ORDER.status,0)

Is it safe to use ActiveRecord pattern with Realm?

╄→尐↘猪︶ㄣ 提交于 2019-12-13 18:12:08
问题 I'm building a little Android app and I find the ActiveRecord pattern pretty handy. But since ActiveAndroid development is quite dead, I turned to Realm instead. I'm surprised nothing is said about this pattern, is it safe to write something like this ? public void delete(){ Realm realm=Realm.getDefaultInstance(); realm.executeTransaction(new Realm.Transaction() { @Override public void execute(Realm realm) { MyClass.this.deleteFromRealm(); } }); realm.close(); } 来源: https://stackoverflow.com

Getting io.realm.exceptions.RealmException: Could not find the generated ValidationList class when trying to get a Realm object

筅森魡賤 提交于 2019-12-13 17:31:15
问题 I could provide some code, but basically i get this exception at a this.realm = Realm.getInstance(context); Of course context is not null. Any ideas? StackTrace: Caused by: io.realm.exceptions.RealmException: Could not find the generated ValidationList class at io.realm.Realm.createAndValidate(Realm.java:203) at io.realm.Realm.create(Realm.java:181) at io.realm.Realm.getInstance(Realm.java:159) at io.realm.Realm.getInstance(Realm.java:128) at com.ithurts.robertharkai.baseproject.realm

Why Realm don't support auto increment primary key?

此生再无相见时 提交于 2019-12-13 17:14:40
问题 Is there some pros or cons to not implement that feature? I know some solutions exist and that it's on there road maps but are there any advantages behind that decision that we are not award of? 回答1: In a discussion on Github (see realm/realm-cocoa#2591) the Realm team said there are no plans for support any auto increment field, even if there's a few lines of code a developer can use for implementing this feature as you said. From a Realm member in the discussion: We decided that we're not

Migrating, but still getting crash on 'RLMException', reason: 'Migration is required

巧了我就是萌 提交于 2019-12-13 16:09:16
问题 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Realm, 1th thing { RLMRealmConfiguration *config = [RLMRealmConfiguration defaultConfiguration]; config.schemaVersion = 2; config.migrationBlock = ^(RLMMigration *migration, uint64_t oldSchemaVersion) { }; config.objectClasses = @[[User class], [UsersMenuItem class]]; [RLMRealm migrateRealm:config]; } ... } I did add a property to the user object, the docu says the new realm

NSPredicate using RLMResults as an argument

▼魔方 西西 提交于 2019-12-13 15:08:08
问题 I am trying to get the difference between two sets of Realm data (and are different objects) by filtering using an NSPredicate, but there is an error that I'm having trouble understanding. My code: RLMResults *topStories = [KFXTopStory allObjects]; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"NONE threadId = %@.topStoryId", topStories]; RLMResults *objectsToDelete = [KFXThread objectsWithPredicate:predicate]; Error: *** Terminating app due to uncaught exception 'Invalid

Error : java.lang.UnsatisfiedLinkError with roboelectric and realm

筅森魡賤 提交于 2019-12-13 12:25:18
问题 Hi I am using realm database for my application and using roboelectric unit testing framework for performing unit testing. I see realm is written in native c code, it has librealm-jni.so file for their functionality. I am getting UnsatisfiedLinkError error, read somewhere that robolectric does not support native libraries. I believe that there must be some way to resolve it. I tried accepted answer of this How to load .so when using Robolectric? but no luck. java.lang.UnsatisfiedLinkError:

Subquery and IN Statement in realm

做~自己de王妃 提交于 2019-12-13 11:32:35
问题 I have three realm objects. Department, section and user. section is a kind of sub department in a department. But there will be users under each section and each department. @interface Department : RLMObject @property NSString *name; @property BOOL isCollapsed; @property (nonatomic, strong) RLMArray<Section> *sections; @property (nonatomic, strong) RLMArray<User> *users; @end @interface Section : RLMObject @property NSString *name; @property BOOL isCollapsed; @property RLMArray<User> *users;