当前位置: 首页>>代码示例>>Java>>正文


Java Realm.getInstance方法代码示例

本文整理汇总了Java中io.realm.Realm.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java Realm.getInstance方法的具体用法?Java Realm.getInstance怎么用?Java Realm.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.realm.Realm的用法示例。


在下文中一共展示了Realm.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: logoutRealmUser

import io.realm.Realm; //导入方法依赖的package包/类
private void logoutRealmUser() {
    //注册成功写数据库
    RealmConfiguration config = new RealmConfiguration.Builder().name("yyox.realm").build();
    Realm objRealm = Realm.getInstance(config);

    //查找
    RealmUser realmUser = objRealm.where(RealmUser.class).findFirst();
    if (realmUser != null) {
        //先删除
        objRealm.beginTransaction();
        RealmResults results = objRealm.where(RealmUser.class).findAll();
        results.deleteAllFromRealm();
        objRealm.commitTransaction();
        //再添加
        objRealm.beginTransaction();
        RealmUser realmUserNew = objRealm.createObject(RealmUser.class);
        realmUserNew.setName("");
        objRealm.commitTransaction();

        mRealmUser = null;
    }
}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:23,代码来源:WEApplication.java

示例2: insert

import io.realm.Realm; //导入方法依赖的package包/类
@Override
public boolean insert(TodoListItem item) {
    Realm realm = Realm.getInstance(configuration);
    final TodoListItemDAO dao = RealmConverter.convert(item);

    realm.beginTransaction();
    try {
        realm.copyToRealm(dao);
        realm.commitTransaction();
    } catch (Throwable throwable) {
        realm.cancelTransaction();
        realm.close();
        return false;
    }
    realm.close();
    return true;
}
 
开发者ID:djuelg,项目名称:Neuronizer,代码行数:18,代码来源:TodoListRepositoryImpl.java

示例3: populateRealmIgnored

import io.realm.Realm; //导入方法依赖的package包/类
private void populateRealmIgnored() {
    final Realm realm =
        Realm.getInstance(new RealmConfiguration.Builder().name("realm.ignored").build());

    final Author moses = new Author();
    moses.name = "Moses";
    final Book genesis = new Book();
    genesis.index = 0;
    genesis.name = "Genesis";
    genesis.author = moses;

    realm.beginTransaction();
    realm.copyToRealmOrUpdate(genesis);
    realm.commitTransaction();

    realm.close();
}
 
开发者ID:xizzhu,项目名称:stetho-realm,代码行数:18,代码来源:App.java

示例4: processRawData

import io.realm.Realm; //导入方法依赖的package包/类
public static ReadingData processRawData(String sensorTagId, byte[] data) {
    // copy data to database
    Realm realmProcessedData = Realm.getInstance(realmConfigProcessedData);
    Realm realmRawData = Realm.getInstance(realmConfigRawData);

    // commit raw data into realm for debugging
    realmRawData.beginTransaction();
    RawTagData rawTagData = realmRawData.copyToRealmOrUpdate(new RawTagData(sensorTagId, data));
    realmRawData.commitTransaction();

    // commit processed data into realm
    realmProcessedData.beginTransaction();
    ReadingData readingData = realmProcessedData.copyToRealmOrUpdate(new ReadingData(rawTagData));
    realmProcessedData.commitTransaction();

    realmProcessedData.close();
    realmRawData.close();

    return readingData;
}
 
开发者ID:DorianScholz,项目名称:OpenLibre,代码行数:21,代码来源:NfcVReaderTask.java

示例5: onCreate

import io.realm.Realm; //导入方法依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    Settings.init(this);
    Realm.init(this);
    realm = Realm.getInstance(getRealmConfiguration());
    if (!BuildConfig.DEBUG) {
        Fabric.with(this, new Crashlytics());
    } else {
        initStrictMode();
    }
}
 
开发者ID:Omico,项目名称:CurrentActivity,代码行数:13,代码来源:CurrentActivity.java

示例6: RealmHelper

import io.realm.Realm; //导入方法依赖的package包/类
private RealmHelper() {
    try {
        mRealm = Realm.getDefaultInstance();
    } catch (Exception e) {
        RealmConfiguration config = new RealmConfiguration.Builder()
                .deleteRealmIfMigrationNeeded()
                .build();
        mRealm = Realm.getInstance(config);
    }


}
 
开发者ID:emqtt,项目名称:EMQ-Android-Toolkit,代码行数:13,代码来源:RealmHelper.java

示例7: getViewAt

import io.realm.Realm; //导入方法依赖的package包/类
@Override
public RemoteViews getViewAt(int position) {
    RemoteViews remoteViews = new RemoteViews(
            context.getPackageName(), R.layout.item_package_for_widget);

    Realm rlm = Realm.getInstance(new RealmConfiguration.Builder()
            .deleteRealmIfMigrationNeeded()
            .name(DATABASE_NAME)
            .build());
    List<Package> results = rlm.copyFromRealm(rlm.where(Package.class)
            .notEqualTo("state", String.valueOf(Package.STATUS_DELIVERED))
            .findAllSorted("timestamp", Sort.DESCENDING));

    Package p = results.get(position);

    if (p.getData() != null && p.getData().size() > 0) {
        int state = Integer.parseInt(p.getState());
        remoteViews.setTextViewText(R.id.textViewStatus,
                String.valueOf(packageStatus[state]) + " - " + p.getData().get(0).getContext());
        remoteViews.setTextViewText(R.id.textViewTime, p.getData().get(0).getTime());
    } else {
        remoteViews.setTextViewText(R.id.textViewTime, "");
        remoteViews.setTextViewText(R.id.textViewStatus, statusError);
    }

    remoteViews.setTextViewText(R.id.textViewPackageName, p.getName());
    remoteViews.setTextViewText(R.id.textViewAvatar, p.getName().substring(0, 1));
    remoteViews.setImageViewResource(R.id.imageViewAvatar, p.getColorAvatar());

    Intent intent = new Intent();
    intent.putExtra(PackageDetailsActivity.PACKAGE_ID, p.getNumber());
    remoteViews.setOnClickFillInIntent(R.id.layoutPackageItemMain, intent);

    return remoteViews;
}
 
开发者ID:TonnyL,项目名称:Espresso,代码行数:36,代码来源:WidgetListFactory.java

示例8: get

import io.realm.Realm; //导入方法依赖的package包/类
@Override
public Optional<Note> get(String uuid) {
    Realm realm = Realm.getInstance(configuration);
    Optional<NoteDAO> noteDAO = Optional.fromNullable(realm.where(NoteDAO.class).equalTo("uuid", uuid).findFirst());
    Optional<Note> note = noteDAO.transform(new NoteDAOConverter());
    realm.close();
    return note;

}
 
开发者ID:djuelg,项目名称:Neuronizer,代码行数:10,代码来源:NoteRepositoryImpl.java

示例9: getHeaderCountOfTodoList

import io.realm.Realm; //导入方法依赖的package包/类
@Override
public int getHeaderCountOfTodoList(String uuid) {
    Realm realm = Realm.getInstance(configuration);
    int size = (int) realm.where(TodoListHeaderDAO.class).equalTo("parentTodoListUuid", uuid).count();
    realm.close();
    return size;
}
 
开发者ID:djuelg,项目名称:Neuronizer,代码行数:8,代码来源:TodoListRepositoryImpl.java

示例10: loadDataFromDB

import io.realm.Realm; //导入方法依赖的package包/类
private void loadDataFromDB() {
    Realm realm = Realm.getInstance(ApplicationController.getInstance().getRealmConfig());
    RealmResults<RMoviesDTO> rMoviesDTOs = realm.where(RMoviesDTO.class).findAllSorted("release_date", Sort.DESCENDING);
    for (RMoviesDTO rMoviesDTO : rMoviesDTOs) {
        moviesDTOs.add(new MoviesDTO(rMoviesDTO));
    }
    moviesAdapter.notifyDataSetChanged();
    realm.close();
}
 
开发者ID:Auto-Droid,项目名称:TMDB-App,代码行数:10,代码来源:MovieFragment.java

示例11: before

import io.realm.Realm; //导入方法依赖的package包/类
@BeforeExperiment
public void before() {
    RealmConfiguration config = new RealmConfiguration.Builder().build();
    Realm.deleteRealm(config);
    realm = Realm.getInstance(config);
    realm.beginTransaction();
    writeObject = realm.createObject(AllTypes.class);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:RealmObjectWriteBenchmarks.java

示例12: logout

import io.realm.Realm; //导入方法依赖的package包/类
/**
 * Logs the user out of their current session.
 */
public static void logout(Context context)
{
	// Destroy USER database
	Realm realm = Realm.getInstance(getRealmConfig(context, RealmLevel.USER));
	realm.beginTransaction();
	realm.deleteAll();
	realm.commitTransaction();

	// Clear "session"
	USER = null;
	USERNAME = null;
	DEK = null;
}
 
开发者ID:LDLN,项目名称:Responder-Android,代码行数:17,代码来源:LDLN.java

示例13: getSectionsOfTodoListId

import io.realm.Realm; //导入方法依赖的package包/类
@Override
public List<TodoListSection> getSectionsOfTodoListId(String uuid) {
    Realm realm = Realm.getInstance(configuration);
    RealmResults<TodoListHeaderDAO> headerDAOs = realm.where(TodoListHeaderDAO.class).equalTo("parentTodoListUuid", uuid).findAll();
    List<TodoListSection> sections = new ArrayList<>(headerDAOs.size());
    for (TodoListHeaderDAO dao : headerDAOs) {
        sections.add(constructSection(realm, dao));
    }
    realm.close();
    return sections;
}
 
开发者ID:djuelg,项目名称:Neuronizer,代码行数:12,代码来源:TodoListRepositoryImpl.java

示例14: open

import io.realm.Realm; //导入方法依赖的package包/类
public void open() {
    // Don't use Realm.setDefaultInstance() in library projects. It is unsafe as app developers can override the
    // default configuration. So always use explicit configurations in library projects.
    realm = Realm.getInstance(realmConfig);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:6,代码来源:Zoo.java

示例15: ViewerFileDao

import io.realm.Realm; //导入方法依赖的package包/类
@Inject
public ViewerFileDao(RealmConfiguration realmConfiguration) {
    super(Realm.getInstance(realmConfiguration), ViewerFile.class);
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:5,代码来源:ViewerFileDao.java


注:本文中的io.realm.Realm.getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。