Java Code Examples for io.realm.RealmResults.deleteAllFromRealm()

The following are Jave code examples for showing how to use deleteAllFromRealm() of the io.realm.RealmResults class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: yyox   File: UserSettingActivity.java   View Source Code Vote up 6 votes
public void btn_logout_click(View v) {
    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();

    }
    mPresenter.requestLogout(this);
    WEApplication weApplication = (WEApplication) getApplication();
    weApplication.setRealmUser(null);

    Intent intent = new Intent();
    setResult(CodeDefine.SETTING_RESULT, intent);
}
 
Example 2
Project: yyox   File: WEApplication.java   View Source Code Vote up 6 votes
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;
    }
}
 
Example 3
Project: ingetin   File: RealmHelper.java   View Source Code Vote up 5 votes
/**
 * method menghapus Profil berdasarkan id
 *
 * @param id
 */
public void deleteProfil(int id) {
    realm.beginTransaction();
    RealmResults<Profil> dataResults = realm.where(Profil.class).equalTo("id", id).findAll();

    dataResults.deleteAllFromRealm();

    realm.commitTransaction();

    showToast("Hapus data berhasil.");
}
 
Example 4
Project: ingetin   File: RealmHelper.java   View Source Code Vote up 5 votes
/**
 * method menghapus Akademik berdasarkan id
 *
 * @param id
 */
public void deleteAkademmik(int id) {
    realm.beginTransaction();
    RealmResults<Akademik> dataResults = realm.where(Akademik.class).equalTo("id", id).findAll();

    dataResults.deleteAllFromRealm();

    realm.commitTransaction();

    showToast("Hapus data berhasil.");
}
 
Example 5
Project: ingetin   File: RealmHelper.java   View Source Code Vote up 5 votes
/**
 * method menghapus Organisasi berdasarkan id
 *
 * @param id
 */
public void deleteOrganisasi(int id) {
    realm.beginTransaction();
    RealmResults<Organisasi> dataResults = realm.where(Organisasi.class).equalTo("id", id).findAll();

    dataResults.deleteAllFromRealm();

    realm.commitTransaction();

    showToast("Hapus data berhasil.");
}
 
Example 6
Project: ingetin   File: RealmHelper.java   View Source Code Vote up 5 votes
/**
 * method menghapus Lainnya berdasarkan id
 *
 * @param id
 */
public void deleteLainnya(int id) {
    realm.beginTransaction();
    RealmResults<Lainnya> dataResults = realm.where(Lainnya.class).equalTo("id", id).findAll();

    dataResults.deleteAllFromRealm();

    realm.commitTransaction();

    showToast("Hapus data berhasil.");
}
 
Example 7
Project: kyandroid   File: LocalData.java   View Source Code Vote up 5 votes
public static <O extends  RealmObject> void delete(Realm realmInstance, QueryFilters filters, Class<O> clazz){
    Realm realm = realmInstance;
    realm.beginTransaction();
    RealmQuery<O> query = realm.where(clazz);
    query = filters.copyToRealmQuery(query);
    final RealmResults<O> results = query.findAll();
    results.deleteAllFromRealm();
    realm.commitTransaction();
    realm.close();
}
 
Example 8
Project: Raffler-Android   File: AppManager.java   View Source Code Vote up 5 votes
/**
 * save contacts data into local storage
 * @param contacts
 */
public static void saveContacts(final RealmList<RealmContact> contacts ){
    Realm realm = Realm.getDefaultInstance();
    realm.beginTransaction();
    final RealmResults<RealmContact> results = realm.where(RealmContact.class).findAll();
    results.deleteAllFromRealm();
    realm.copyToRealmOrUpdate(contacts);
    realm.commitTransaction();
}
 
Example 9
Project: Plamber-Android   File: BookUtilsDB.java   View Source Code Vote up 5 votes
public void removeBookFromDatabase(String id) {
    Realm realm = Realm.getDefaultInstance();
    realm.beginTransaction();
    RealmResults<BookDB> results = realm.where(BookDB.class).equalTo("idBook", id).findAll();
    results.deleteAllFromRealm();
    realm.commitTransaction();
}
 
Example 10
Project: Plamber-Android   File: BookUtilsDB.java   View Source Code Vote up 5 votes
public void deleteAllFromDB() {
    Realm realm = Realm.getDefaultInstance();
    realm.beginTransaction();
    RealmResults<BookDB> results = realm.where(BookDB.class).findAll();
    results.deleteAllFromRealm();
    realm.commitTransaction();
}
 
Example 11
Project: Android-Wear-Projects   File: MainActivity.java   View Source Code Vote up 3 votes
public void Reset(){
    RealmResults<StepCounts> results = realm.where(StepCounts.class).findAll();

    realm.beginTransaction();

    results.deleteAllFromRealm();

    realm.commitTransaction();
}
 
Example 12
Project: Android-Wear-Projects   File: MainActivity.java   View Source Code Vote up 3 votes
public void Reset(){
    RealmResults<StepCounts> results = realm.where(StepCounts.class).findAll();

    realm.beginTransaction();

    results.deleteAllFromRealm();

    realm.commitTransaction();
}
 
Example 13
Project: Android-Wear-Projects   File: MainActivity.java   View Source Code Vote up 3 votes
public void deleteRecord(String id){
    RealmResults<Note> results = realm.where(Note.class).equalTo("id", id).findAll();

    realm.beginTransaction();

    results.deleteAllFromRealm();

    realm.commitTransaction();
}