當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。