コード例 #1
0
  // update a server
  public static void update(SQLiteDatabase database, String table, GenericListItem item) {
    AppState.log(
        TAG,
        String.format(
            "update 3: database = %s, table = %s, name = %s", database, table, item.firstGet()));

    Server server = (Server) item;
    ContentValues values = new ContentValues();
    values.put(KEY_SERVER_HOST_NAME, server.serverHostNameGet());
    values.put(KEY_SERVER_INTERNET_ADDRESS, server.serverInternetAddressGet());
    values.put(KEY_SERVER_USER_NAME, server.serverUserNameGet());
    values.put(KEY_SERVER_USER_PASSWORD, server.serverUserPasswordGet());
    values.put(
        KEY_SERVER_EXPORT_DIRECTORIES,
        Server.serverExportDirectoriesStringGet(server.serverExportDirectoriesGet()));
    database.update(table, values, KEY_SERVER_HOST_NAME + "=" + server.serverHostNameGet(), null);
  }
コード例 #2
0
  // insert a server
  public static void insert(SQLiteDatabase database, GenericListItem item) {
    Server server = (Server) item;
    SQLiteStatement serversTableInsertStmt = database.compileStatement(SERVERS_TABLE_INSERT);
    serversTableInsertStmt.bindString(KEY_SERVER_HOST_NAME_INDEX, server.serverHostNameGet());
    serversTableInsertStmt.bindString(
        KEY_SERVER_INTERNET_ADDRESS_INDEX, server.serverInternetAddressGet());
    serversTableInsertStmt.bindString(KEY_SERVER_USER_NAME_INDEX, server.serverUserNameGet());
    serversTableInsertStmt.bindString(
        KEY_SERVER_USER_PASSWORD_INDEX, server.serverUserPasswordGet());
    serversTableInsertStmt.bindString(
        KEY_SERVER_EXPORT_DIRECTORIES_INDEX,
        Server.serverExportDirectoriesStringGet(server.serverExportDirectoriesGet()));
    serversTableInsertStmt.executeInsert();
    serversTableInsertStmt.close();

    AppState.logX(
        TAG,
        String.format(
            "insert 3: server = %s, inet addr = %s, exports = %s",
            server.serverHostNameGet(),
            server.serverInternetAddressGet(),
            Server.serverExportDirectoriesStringGet(server.serverExportDirectoriesGet())));
  }