Android Open Source - digital-ocean-swimmer Domain Dao

From Project

Back to project page digital-ocean-swimmer.


The source code is released under:

MIT License

If you think the Android project digital-ocean-swimmer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

// w  w  w  . j a  va  2 s . c o  m
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

import com.yassirh.digitalocean.model.Domain;

public class DomainDao extends SqlDao<Domain> {

  private DatabaseHelper databaseHelper;

  public DomainDao(DatabaseHelper databaseHelper) {
    this.databaseHelper = databaseHelper;

  public long create(Domain domain) {    
    ContentValues values = new ContentValues();
    values.put(DomainTable.NAME, domain.getName());
    values.put(DomainTable.TTL, domain.getTtl());
    values.put(DomainTable.ZONE_FILE, domain.getLiveZoneFile());
        return db.insertWithOnConflict(getTableHelper().TABLE_NAME, null, values,SQLiteDatabase.CONFLICT_REPLACE);

  public Domain newInstance(Cursor c) {
    Domain domain = new Domain();
    return domain;

  public DatabaseHelper getDatabaseHelper() {
    return this.databaseHelper;

  public TableHelper getTableHelper() {
    return new DomainTable();

  public void deleteByName(String domainName) {
    db.delete(getTableHelper().TABLE_NAME,DomainTable.NAME + " = ?", new String[]{domainName});
    // TODO: Delete domain records 

Java Source Code List