Пример #1
0
 public void deleteTran(Account acct, String transID) {
   String[] args = {Integer.toString(acct.ID), transID};
   db.beginTransaction();
   try {
     db.delete("trans", "acct_id=? and trans_id=?", args);
     db.setTransactionSuccessful();
   } finally {
     db.endTransaction();
   }
 }
Пример #2
0
 private void updateTran(Transaction trans) {
   db.beginTransaction();
   try {
     ContentValues newValue = tranValues(trans);
     String[] args = {Integer.toString(trans.ID)};
     db.update("trans", newValue, "_id=?", args);
     db.setTransactionSuccessful();
   } finally {
     db.endTransaction();
   }
 }
Пример #3
0
 public void onPressClear(View view) {
   // Do something in response to button
   DataBaseHelper databasehelper = new DataBaseHelper(this);
   SQLiteDatabase db = databasehelper.getWritableDatabase();
   if (db != null) {
     // Se elimina la versión anterior de la tabla
     db.execSQL("DROP TABLE IF EXISTS " + databasehelper.TABLA);
     // Se utiliza para poder crear la nueva base de datos
     databasehelper.onCreate(db);
   }
 }
Пример #4
0
 private void updateAccount(Account acct) {
   db.beginTransaction();
   try {
     ContentValues newValue = acctValues(acct);
     String[] args = {Integer.toString(acct.ID)};
     db.update("acct", newValue, "_id=?", args);
     db.setTransactionSuccessful();
   } finally {
     db.endTransaction();
   }
 }
Пример #5
0
  // metodo para insertar a la tabla
  private void insertPrso(String nombre, String ciudad) {
    DataBaseHelper databasehelper = new DataBaseHelper(this);
    SQLiteDatabase db = databasehelper.getWritableDatabase();
    if (db != null) {
      ContentValues cv = new ContentValues();
      cv.put(DataBaseHelper.NOMBRE, nombre);
      cv.put(DataBaseHelper.CIUDAD, ciudad);

      db.insert("tabla", DataBaseHelper.NOMBRE, cv);
      db.close();
    }
  }
Пример #6
0
 private int addAccount(Account acct) {
   db.beginTransaction();
   int acct_id;
   try {
     ContentValues newValue = acctValues(acct);
     acct_id = (int) db.insertOrThrow("acct", "name", newValue);
     acct.ID = acct_id;
     db.setTransactionSuccessful();
   } finally {
     db.endTransaction();
   }
   return acct_id;
 }
Пример #7
0
 public Cursor acctList(String constraint) {
   if (constraint == null) {
     return db.query("acct", AC_COLS, null, null, null, null, "name");
   } else {
     return db.query(
         "acct",
         AC_COLS,
         "name like ?",
         new String[] {"%" + constraint + "%"},
         null,
         null,
         "name");
   }
 }
Пример #8
0
  private int addTran(Transaction trans) {
    db.beginTransaction();
    int tran_id;
    try {
      ContentValues newValue = tranValues(trans);
      tran_id = (int) db.insertOrThrow("trans", "acct_id", newValue);
      trans.ID = tran_id;

      db.setTransactionSuccessful();
    } finally {
      db.endTransaction();
    }
    return tran_id;
  }
Пример #9
0
 private boolean tranExists(Transaction trans) {
   String[] args = {Integer.toString(trans.acct.ID), trans.transID};
   Cursor cur = db.query("trans", ID_COLS, "acct_id=? and trans_id=?", args, null, null, null);
   try {
     return cur.moveToNext();
   } finally {
     cur.close();
   }
 }
Пример #10
0
  public Account getAccount(int ID) {
    Account acct = null;
    String[] args = {Integer.toString(ID)};
    Cursor cur = db.query("acct", AC_COLS, "_id=?", args, null, null, null);
    try {
      if (!cur.moveToNext()) return null;
      acct = getAccountFromCursor(cur);
    } finally {
      cur.close();
    }

    return acct;
  }
Пример #11
0
  public void establishAccount(ServiceAcctInfo acct) {
    String[] args = {Integer.toString(acct.ID)};
    Cursor cur = db.query("acct", AC_COLS, "service_id=?", args, null, null, null);
    try {
      if (cur.moveToNext()) return;
    } finally {
      cur.close();
    }

    Account newAcct = new Account();
    newAcct.serviceId = acct.ID;
    newAcct.name = acct.desc;
    addAccount(newAcct);
  }
Пример #12
0
 public void close() {
   db.close();
 }
Пример #13
0
 public void wipeTable(SQLiteDatabase db) {
   for (String cmd : DROP_TABLE) {
     db.execSQL(cmd);
   }
   onCreate(db);
 }
Пример #14
0
 @Override
 public void onCreate(SQLiteDatabase db) {
   for (String cmd : CREATE_TABLE) {
     db.execSQL(cmd);
   }
 }
Пример #15
0
 public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
   db.execSQL("DROP TABLE IF EXISTS contact");
   onCreate(db);
 }
Пример #16
0
 public void onCreate(SQLiteDatabase db) {
   db.execSQL(
       "CREATE TABLE contact ( _id INTEGER PRIMARY KEY AUTOINCREMENT, " + "name TEXT, tel TEXT);");
 }